& images);
/**
* Sets the window manager of this window.
*
* Note that this method is used by WindowManager
to maintain
* a backpointer. Clients must not call the method directly.
*
*
* @param manager
* the window manager, or null
if none
*/
void SetWindowManager(WindowManager* manager);
/**
* Sets the exception handler for this application.
*
* Note that the handler may only be set once. Subsequent calls to this method will be
* ignored.
*
*
* @param handler
* the exception handler for the application.
*/
static void SetExceptionHandler(IExceptionHandler::Pointer handler);
/**
* Sets the default parent for modal Windows. This will be used to locate
* the parent for any modal Window constructed with a null parent.
*
* @param provider shell provider that will be used to locate the parent shell
* whenever a Window is created with a null parent
* @since 3.1
*/
static void SetDefaultModalParent(IShellProvider::Pointer provider);
};
}
#endif /* BERRYWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
index 10b11760e0..9f6bae8aac 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryWorkbenchPart.h
@@ -1,256 +1,256 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef __BERRY_WORKBENCH_PART_H__
#define __BERRY_WORKBENCH_PART_H__
#include "berryIWorkbenchPart.h"
#include "berryIWorkbenchPartSite.h"
#include
#include
#include
namespace berry {
/**
* \ingroup org_blueberry_ui_qt
*
* Abstract base implementation of all workbench parts.
*
* This class is not intended to be subclassed by clients outside this
* package; clients should instead subclass ViewPart
or
* EditorPart
.
*
*
* @see org.blueberry.ui.part.ViewPart
* @see org.blueberry.ui.part.EditorPart
* @noextend This class is not intended to be subclassed by clients.
*/
class BERRY_UI_QT WorkbenchPart : public QObject,
public virtual IWorkbenchPart, public IExecutableExtension
{
Q_OBJECT
Q_INTERFACES(berry::IExecutableExtension);
public:
berryObjectMacro(WorkbenchPart)
~WorkbenchPart();
private:
QString m_Title;
QIcon m_TitleImage;
QString m_ToolTip;
IConfigurationElement::Pointer m_ConfigElement;
IWorkbenchPartSite::Pointer m_PartSite;
QString m_PartName;
QString m_ContentDescription;
QHash partProperties;
IPropertyChangeListener::Events partChangeEvents;
void InternalSetContentDescription(const QString& description);
void InternalSetPartName(const QString& partName);
protected:
WorkbenchPart();
/**
* Returns the configuration element for this part. The configuration element
* comes from the plug-in registry entry for the extension defining this part.
*
* @return the configuration element for this part
*/
IConfigurationElement::Pointer GetConfigurationElement() const
{
return m_ConfigElement;
}
/**
* Returns the default title image.
*
* @return the default image
*/
// protected Image getDefaultImage() {
// return PlatformUI.getWorkbench().getSharedImages().getImage(
// ISharedImages.IMG_DEF_VIEW);
// }
/**
* Sets the part site.
*
* Subclasses must invoke this method from IEditorPart.init
* and IViewPart.init
.
*
* @param site the workbench part site
*/
void SetSite(IWorkbenchPartSite::Pointer site);
/**
* Checks that the given site is valid for this type of part.
* The default implementation does nothing.
*
* @param site the site to check
*/
virtual void CheckSite(IWorkbenchPartSite::Pointer site);
/**
* Sets or clears the title image of this part.
*
* @param titleImage the title image, or null
to clear
*/
virtual void SetTitleImage(const QIcon& titleImage);
/**
* Sets or clears the title tool tip text of this part. Clients should
* call this method instead of overriding getTitleToolTip
*
* @param toolTip the new tool tip text, or null
to clear
*/
virtual void SetTitleToolTip(const QString& toolTip);
/**
* Sets the name of this part. The name will be shown in the tab area for
* the part. Clients should call this method instead of overriding getPartName.
* Setting this to the empty string will cause a default part name to be used.
*
* @param partName the part name, as it should be displayed in tabs.
*/
virtual void SetPartName(const QString& partName);
/**
* Sets the content description for this part. The content description is typically
* a short string describing the current contents of the part. Setting this to the
* empty string will cause a default content description to be used. Clients should
* call this method instead of overriding getContentDescription(). For views, the
* content description is shown (by default) in a line near the top of the view. For
* editors, the content description is shown beside the part name when showing a
* list of editors. If the editor is open on a file, this typically contains the path
* to the input file, without the filename or trailing slash.
*
* @param description the content description
*/
virtual void SetContentDescription(const QString& description);
void FirePropertyChanged(const QString& key,
const QString& oldValue, const QString& newValue);
void FirePropertyChange(int propertyId);
public:
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
void AddPropertyListener(IPropertyChangeListener* l);
void RemovePropertyListener(IPropertyChangeListener* l);
void SetPartProperty(const QString& key, const QString& value);
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperty(java.lang.String)
*/
QString GetPartProperty(const QString& key) const;
/* (non-Javadoc)
* @see org.blueberry.ui.IWorkbenchPart3#getPartProperties()
*/
const QHash& GetPartProperties() const;
/**
* {@inheritDoc}
* The WorkbenchPart
implementation of this
* IExecutableExtension
records the configuration element in
* and internal state variable (accessible via getConfigElement
).
* It also loads the title image, if one is specified in the configuration element.
* Subclasses may extend.
*
* Should not be called by clients. It is called by the core plugin when creating
* this executable extension.
*/
void SetInitializationData(const IConfigurationElement::Pointer& cfig,
const QString& propertyName, const Object::Pointer& data);
/*
* Creates the controls for this workbench part.
*
* Subclasses must implement this method. For a detailed description of the
* requirements see IWorkbenchPart
*
*
* @param parent the parent control
* @see IWorkbenchPart
*/
- virtual void CreatePartControl(void* parent) = 0;
+ virtual void CreatePartControl(QWidget* parent) = 0;
/* (non-Javadoc)
* Asks this part to take focus within the workbench.
*
* Subclasses must implement this method. For a detailed description of the
* requirements see IWorkbenchPart
*
*
* @see IWorkbenchPart
*/
virtual void SetFocus() = 0;
/*
* Method declared on IWorkbenchPart.
*/
IWorkbenchPartSite::Pointer GetSite() const;
/**
* {@inheritDoc}
*
* It is considered bad practise to overload or extend this method.
* Parts should call setPartName to change their part name.
*
*/
QString GetPartName() const;
/**
* {@inheritDoc}
*
* It is considered bad practise to overload or extend this method.
* Parts should call setContentDescription to change their content description.
*
*/
QString GetContentDescription() const;
/* (non-Javadoc)
* Method declared on IWorkbenchPart.
*/
QIcon GetTitleImage() const;
/* (non-Javadoc)
* Gets the title tool tip text of this part.
*
* @return the tool tip text
*/
QString GetTitleToolTip() const;
};
} // namespace berry
#endif // __BERRY_WORKBENCH_PART_H__
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.cpp
index 2291f5075f..b6a8445f3e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.cpp
@@ -1,42 +1,42 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryGuiTkControlEvent.h"
namespace berry
{
namespace GuiTk
{
ControlEvent::ControlEvent() :
Event()
{
}
-ControlEvent::ControlEvent(void* item, int x, int y, int width, int height) :
+ControlEvent::ControlEvent(QWidget* item, int x, int y, int width, int height) :
Event()
{
this->item = item;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
index 05157ffc58..4979b40597 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkControlEvent.h
@@ -1,55 +1,55 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYGUITKCONTROLEVENT_H_
#define BERRYGUITKCONTROLEVENT_H_
#include "berryGuiTkEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* controls being moved or resized.
*
* @see ControlListener
* @see Sample code and further information
*/
class BERRY_UI_QT ControlEvent: public Event
{
public:
berryObjectMacro(ControlEvent)
ControlEvent();
- ControlEvent(void* item, int x = 0, int y = 0, int width = 0, int height = 0);
+ ControlEvent(QWidget* item, int x = 0, int y = 0, int width = 0, int height = 0);
};
}
}
#endif /* BERRYGUITKCONTROLEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkEvent.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkEvent.h
index 17d072cfc2..0e12293d55 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkEvent.h
@@ -1,146 +1,146 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYGUITKEVENT_H_
#define BERRYGUITKEVENT_H_
#include
#include
#include
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* GUI events.
*
* Note: The fields that are filled in depend on the widget.
*
*
*/
class BERRY_UI_QT Event: public Object
{
public:
- berryObjectMacro(Event);
+ berryObjectMacro(Event)
Event();
/**
* the widget that issued the event
*/
- void* item;
+ QWidget* item;
/**
* the event specific detail field, as defined by the detail constants
* in class Constants
*/
int detail;
/**
* depending on the event type, the x offset of the bounding
* rectangle of the region that requires painting or the
* widget-relative, x coordinate of the pointer at the
* time the mouse button was pressed or released
*/
int x;
/**
* depending on the event type, the y offset of the bounding
* rectangle of the region that requires painting or the
* widget-relative, y coordinate of the pointer at the
* time the mouse button was pressed or released
*/
int y;
/**
* the width of the bounding rectangle of the
* region that requires painting
*/
int width;
/**
* the height of the bounding rectangle of the
* region that requires painting
*/
int height;
/**
* the button that was pressed or released; 1 for the
* first button, 2 for the second button, and 3 for the
* third button, etc.
*/
int button;
/**
* depending on the event, the character represented by the key
* that was typed. This is the final character that results
* after all modifiers have been applied. For example, when the
* user types Ctrl+A, the character value is 0x01 (ASCII SOH).
* It is important that applications do not attempt to modify the
* character value based on a stateMask (such as SWT.CTRL) or the
* resulting character will not be correct.
*/
char character;
/**
* depending on the event, the key code of the key that was typed,
* as defined by the key code constants in class SWT
.
* When the character field of the event is ambiguous, this field
* contains the unaffected value of the original character. For
* example, typing Ctrl+M or Enter both result in the character '\r'
* but the keyCode field will also contain '\r' when Enter was typed
* and 'm' when Ctrl+M was typed.
*/
int keyCode;
/**
* depending on the event, the state of the keyboard modifier
* keys and mouse masks at the time the event was generated.
*/
int stateMask;
/**
* depending on the event, the new text that will be inserted.
* Setting this field will change the text that is about to
* be inserted or deleted.
*/
QString text;
/**
* depending on the event, a flag indicating whether the operation
* should be allowed. Setting this field to false will cancel the
* operation.
*/
bool doit;
QString ToString() const;
};
}
}
#endif /* BERRYGUITKEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.cpp
index 1393c784ef..8416e8d1f3 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.cpp
@@ -1,35 +1,35 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryGuiTkSelectionEvent.h"
#include
namespace berry
{
namespace GuiTk
{
-SelectionEvent::SelectionEvent(void* item) :
+SelectionEvent::SelectionEvent(QWidget* item) :
Event()
{
this->item = item;
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.h
index 3605916ef4..01b26dffd2 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/guitk/berryGuiTkSelectionEvent.h
@@ -1,56 +1,56 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYGUITKSELECTIONEVENT_H_
#define BERRYGUITKSELECTIONEVENT_H_
#include "berryGuiTkEvent.h"
namespace berry
{
namespace GuiTk
{
/**
* Instances of this class are sent as a result of
* widgets being selected.
*
* @see ISelectionListener
*/
class BERRY_UI_QT SelectionEvent: public Event
{
public:
berryObjectMacro(SelectionEvent);
/**
* Constructs a new instance of this class based on the
* information in the given untyped event.
*
* @param item the GUI dependent widget which has been selected
*/
- SelectionEvent(void* item);
+ SelectionEvent(QWidget* item);
};
}
}
#endif /* BERRYGUITKSELECTIONEVENT_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
index bf970afb08..8c236a418f 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.cpp
@@ -1,540 +1,540 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryDetachedWindow.h"
#include "berryIWorkbenchPartConstants.h"
#include "berryISaveablePart.h"
#include "berryWorkbenchWindow.h"
#include "berryWorkbenchConstants.h"
#include "berryEditorManager.h"
#include "berryDragUtil.h"
namespace berry
{
DetachedWindow::ShellListener::ShellListener(DetachedWindow* wnd) :
window(wnd)
{
}
void DetachedWindow::ShellListener::ShellClosed(const ShellEvent::Pointer& e)
{
// hold on to a reference of the DetachedWindow instance
// (otherwise, wnd->HandleClose() woulde delete the DetachedWindow
// instance too early, trying to write to members afterwards)
DetachedWindow::Pointer wnd(window);
// only continue to close if the handleClose
// wasn't canceled
e->doit = wnd->HandleClose();
}
DetachedWindow::ShellControlListener::ShellControlListener(DetachedWindow* wnd) :
window(wnd)
{
}
GuiTk::IControlListener::Events::Types DetachedWindow::ShellControlListener::GetEventTypes() const
{
return Events::RESIZED;
}
void DetachedWindow::ShellControlListener::ControlResized(
GuiTk::ControlEvent::Pointer e)
{
window->folder->SetBounds(
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(e->item));
}
DetachedWindow::DetachedWindow(WorkbenchPage* workbenchPage)
: folder(new PartStack(workbenchPage, false))
, page(workbenchPage)
, hideViewsOnClose(true)
, shellListener(new ShellListener(this))
, resizeListener(new ShellControlListener(this))
{
}
void DetachedWindow::PropertyChange(const Object::Pointer& /*source*/, int propId)
{
if (propId == IWorkbenchPartConstants::PROP_TITLE)
{
this->UpdateTitle();
}
else if (propId == PartStack::PROP_SELECTION)
{
this->ActivePartChanged(this->GetPartReference(folder->GetSelection()));
}
}
Shell::Pointer DetachedWindow::GetShell()
{
return windowShell;
}
void DetachedWindow::Create()
{
folder->AddListener(this);
windowShell
= page->GetWorkbenchWindow().Cast () ->GetDetachedWindowPool()->AllocateShell(
shellListener.data());
windowShell->SetData(Object::Pointer(this));
windowShell->SetText("");
DragUtil::AddDragTarget(windowShell->GetControl(), this);
hideViewsOnClose = true;
if (bounds.isEmpty())
{
QRect windowRect = page->GetWorkbenchWindow()->GetShell()->GetBounds();
QPoint center(windowRect.x() + windowRect.width() / 2, windowRect.y()
- windowRect.height() / 2);
bounds = QRect(center.x() - 150, center.y() + 100, 300, 200);
}
// Force the rect into the current display
QRect dispBounds =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize();
if (bounds.width() > dispBounds.width())
bounds.setWidth(dispBounds.width());
if (bounds.height() > dispBounds.height())
bounds.setHeight(dispBounds.height());
if (bounds.x() + bounds.width() > dispBounds.width())
bounds.setX(dispBounds.width() - bounds.width());
if (bounds.y() + bounds.height() > dispBounds.height())
bounds.setY(dispBounds.height() - bounds.height());
this->GetShell()->SetBounds(bounds);
this->ConfigureShell(windowShell);
this->CreateContents(windowShell->GetControl());
//windowShell->Layout(true);
//folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(windowShell->GetControl()));
}
void DetachedWindow::Add(LayoutPart::Pointer part)
{
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
part->Reparent(shell->GetControl());
}
folder->Add(part);
this->UpdateMinimumSize();
}
bool DetachedWindow::BelongsToWorkbenchPage(
IWorkbenchPage::Pointer workbenchPage)
{
return (workbenchPage == this->page);
}
bool DetachedWindow::Close()
{
hideViewsOnClose = false;
Shell::Pointer shell = this->GetShell();
if (shell != 0)
{
shell->Close();
}
return true;
}
-IDropTarget::Pointer DetachedWindow::Drag(void* /*currentControl*/,
+IDropTarget::Pointer DetachedWindow::Drag(QWidget* /*currentControl*/,
const Object::Pointer& draggedObject, const QPoint& position, const QRect& /*dragRectangle*/)
{
if (draggedObject.Cast () == 0)
{
return IDropTarget::Pointer(0);
}
PartPane::Pointer sourcePart = draggedObject.Cast ();
if (sourcePart->GetWorkbenchWindow() != page->GetWorkbenchWindow())
{
return IDropTarget::Pointer(0);
}
// Only handle the event if the source part is acceptable to the particular PartStack
IDropTarget::Pointer target;
if (folder->AllowsDrop(sourcePart))
{
target = folder->GetDropTarget(draggedObject, position);
if (target == 0)
{
QRect displayBounds =
DragUtil::GetDisplayBounds(folder->GetControl());
if (displayBounds.contains(position))
{
StackDropResult::Pointer stackDropResult(new StackDropResult(
displayBounds, Object::Pointer(0)));
target = folder->CreateDropTarget(sourcePart, stackDropResult);
}
else
{
return IDropTarget::Pointer(0);
}
}
}
return target;
}
ILayoutContainer::ChildrenType DetachedWindow::GetChildren() const
{
return folder->GetChildren();
}
WorkbenchPage::Pointer DetachedWindow::GetWorkbenchPage()
{
return WorkbenchPage::Pointer(this->page);
}
void DetachedWindow::RestoreState(IMemento::Pointer memento)
{
// Read the bounds.
int x = 0;
memento->GetInteger(WorkbenchConstants::TAG_X, x);
int y = 0;
memento->GetInteger(WorkbenchConstants::TAG_Y, y);
int width = 0;
memento->GetInteger(WorkbenchConstants::TAG_WIDTH, width);
int height = 0;
memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, height);
// memento->GetInteger(WorkbenchConstants::TAG_FLOAT);
// Set the bounds.
bounds = QRect(x, y, width, height);
if (GetShell())
{
GetShell()->SetBounds(bounds);
}
// Create the folder.
IMemento::Pointer childMem =
memento->GetChild(WorkbenchConstants::TAG_FOLDER);
if (childMem)
{
folder->RestoreState(childMem);
}
}
void DetachedWindow::SaveState(IMemento::Pointer memento)
{
if (GetShell())
{
bounds = GetShell()->GetBounds();
}
// Save the bounds.
memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x());
memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y());
memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width());
memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height());
// Save the views.
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_FOLDER);
folder->SaveState(childMem);
}
-void* DetachedWindow::GetControl()
+QWidget* DetachedWindow::GetControl()
{
return folder->GetControl();
}
int DetachedWindow::Open()
{
if (this->GetShell() == 0)
{
this->Create();
}
QRect bounds = this->GetShell()->GetBounds();
if (!(bounds == this->GetShell()->GetBounds()))
{
this->GetShell()->SetBounds(bounds);
}
this->GetShell()->SetVisible(true);
folder->SetBounds(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetClientArea(this->GetShell()->GetControl()));
return 0;
}
void DetachedWindow::ActivePartChanged(
IWorkbenchPartReference::Pointer partReference)
{
if (activePart == partReference)
{
return;
}
if (activePart != 0)
{
activePart->RemovePropertyListener(this);
}
activePart = partReference;
if (partReference != 0)
{
partReference->AddPropertyListener(this);
}
this->UpdateTitle();
}
void DetachedWindow::ConfigureShell(Shell::Pointer shell)
{
this->UpdateTitle();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(
shell->GetControl(), resizeListener);
//shell.addListener(SWT.Activate, activationListener);
//shell.addListener(SWT.Deactivate, activationListener);
//TODO DetachedWindow key bindings
// // Register this detached view as a window (for key bindings).
// IContextService contextService = (IContextService) getWorkbenchPage()
// .getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.registerShell(shell, IContextService.TYPE_WINDOW);
//
// page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(shell,
// IWorkbenchHelpContextIds.DETACHED_WINDOW);
}
-void* DetachedWindow::CreateContents(void* parent)
+QWidget* DetachedWindow::CreateContents(QWidget* parent)
{
// Create the tab folder.
folder->CreateControl(parent);
// Reparent each view in the tab folder.
QList detachedChildren;
this->CollectViewPanes(detachedChildren, this->GetChildren());
for (QList::iterator itr = detachedChildren.begin(); itr
!= detachedChildren.end(); ++itr)
{
PartPane::Pointer part = *itr;
part->Reparent(parent);
}
//TODO DetachedWindow listen to folder events (update size?)
// if (folder->GetPresentation()
// instanceof TabbedStackPresentation)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
// AbstractTabFolder tabFolder = stack.getTabFolder();
// tabFolder.addListener(new TabFolderListener()
// {
// public void handleEvent(TabFolderEvent e)
// {
// switch (e.type)
// {
// case TabFolderEvent.EVENT_CLOSE:
// {
// updateMinimumSize();
// break;
// }
// case TabFolderEvent.EVENT_PREFERRED_SIZE:
// {
// updateMinimumSize();
// break;
// }
// }
// }
// });
// }
// Return tab folder control.
return folder->GetControl();
}
void DetachedWindow::UpdateTitle()
{
if (activePart != 0)
{
// Uncomment to set the shell title to match the title of the active part
// String text = activePart.getTitle();
//
// if (!text.equals(s.getText())) {
// s.setText(text);
// }
}
}
void DetachedWindow::UpdateMinimumSize()
{
// // We can only do this for 'Tabbed' stacked presentations.
// if (folder.getPresentation().Cast() != 0)
// {
// TabbedStackPresentation stack = (TabbedStackPresentation) folder.getPresentation();
//
// if (stack->GetPartList().size() == 1)
// {
// // Get the minimum space required for the part
// int width = stack->ComputePreferredSize(true, Constants::INF, Constants::INF, 0);
// int height = stack->ComputePreferredSize(false, Constants::INF, Constants::INF, 0);
//
// // Take the current shell 'trim' into account
// int shellHeight = windowShell->GetBounds().height - windowShell->GetClientArea().height;
// int shellWidth = windowShell->GetBounds().width - windowShell->GetClientArea().width;
//
// windowShell->SetMinimumSize(width + shellWidth, height + shellHeight);
// }
// }
}
IWorkbenchPartReference::Pointer DetachedWindow::GetPartReference(
LayoutPart::Pointer pane)
{
if (pane == 0 || pane.Cast () == 0)
{
return IWorkbenchPartReference::Pointer(0);
}
return pane.Cast ()->GetPartReference();
}
bool DetachedWindow::HandleClose()
{
if (hideViewsOnClose)
{
QList views;
this->CollectViewPanes(views, this->GetChildren());
// Save any dirty views
if (!this->HandleSaves(views))
{
return false; // User canceled the save
}
// OK, go on with the closing
for (QList::iterator itr = views.begin(); itr
!= views.end(); ++itr)
{
PartPane::Pointer child = *itr;
// Only close if closable...
if (child->IsCloseable())
{
page->HideView(child->GetPartReference().Cast ());
// Was the close cancelled?
if (child->GetContainer() != 0)
return false;
}
else
{
page->AttachView(child->GetPartReference().Cast ());
}
}
}
if (folder != 0)
{
folder->Dispose();
}
if (windowShell != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(
windowShell->GetControl(), resizeListener);
// windowShell.removeListener(SWT.Activate, activationListener);
// windowShell.removeListener(SWT.Deactivate, activationListener);
DragUtil::RemoveDragTarget(windowShell->GetControl(), this);
bounds = windowShell->GetBounds();
//TODO DetachedWindow unregister key bindings
// // Unregister this detached view as a window (for key bindings).
// final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
// contextService.unregisterShell(windowShell);
windowShell->SetData(Object::Pointer(0));
windowShell = 0;
}
return true;
}
bool DetachedWindow::HandleSaves(QList views)
{
QList dirtyViews;
for (QList::iterator iterator = views.begin(); iterator
!= views.end(); ++iterator)
{
PartPane::Pointer pane = *iterator;
IViewReference::Pointer ref =
pane->GetPartReference().Cast ();
IViewPart::Pointer part = ref->GetView(false);
if (part.Cast () != 0)
{
ISaveablePart::Pointer saveable = part.Cast ();
if (saveable->IsDirty() && saveable->IsSaveOnCloseNeeded())
{
dirtyViews.push_back(part);
}
}
}
// If there are any prompt to save -before- any closing happens
// FIXME: This code will result in a double prompt if the user
// decides not to save a particular view at this stage they'll
// get a second one from the 'hideView' call...
if (dirtyViews.size() > 0)
{
IWorkbenchWindow::Pointer window = page->GetWorkbenchWindow();
bool success =
EditorManager::SaveAll(dirtyViews, true, true, false, window);
if (!success)
{
return false; // the user canceled.
}
}
return true;
}
void DetachedWindow::CollectViewPanes(QList& result,
const QList& parts)
{
for (QList::const_iterator iter = parts.begin(); iter
!= parts.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast () != 0)
{
result.push_back(part.Cast ());
}
}
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
index 51ecbf4e31..11290515ae 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDetachedWindow.h
@@ -1,196 +1,196 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDETACHEDWINDOW_H_
#define BERRYDETACHEDWINDOW_H_
#include "berryPartStack.h"
#include "berryWorkbenchPage.h"
#include "berryLayoutPart.h"
#include "berryIDragOverListener.h"
#include "berryIShellListener.h"
#include "guitk/berryGuiTkIControlListener.h"
#include "berryShell.h"
namespace berry
{
/**
* TODO: Drag from detached to fast view bar back to detached causes NPE
*/
class DetachedWindow: public Object, private IPropertyChangeListener,
private IDragOverListener
{
public:
berryObjectMacro(DetachedWindow)
private:
PartStack::Pointer folder;
WorkbenchPage* page;
QRect bounds;
Shell::Pointer windowShell;
bool hideViewsOnClose;
struct ShellListener: public IShellListener
{
ShellListener(DetachedWindow* wnd);
void ShellClosed(const ShellEvent::Pointer& e);
private:
DetachedWindow* window;
};
QScopedPointer shellListener;
struct ShellControlListener: public GuiTk::IControlListener
{
ShellControlListener(DetachedWindow* wnd);
Events::Types GetEventTypes() const;
void ControlResized(GuiTk::ControlEvent::Pointer e);
private:
DetachedWindow* window;
};
GuiTk::IControlListener::Pointer resizeListener;
// Listener activationListener = new Listener() {
// public void handleEvent(Event event) {
// switch (event.type) {
// case SWT.Activate:
// page.window.liftRestrictions();
// break;
// case SWT.Deactivate:
// page.window.imposeRestrictions();
// break;
// }
// }
// };
IWorkbenchPartReference::Pointer activePart;
public:
/**
* Create a new FloatingWindow.
*/
DetachedWindow(WorkbenchPage* workbenchPage);
using IPropertyChangeListener::PropertyChange;
void PropertyChange(const Object::Pointer& source, int propId);
Shell::Pointer GetShell();
void Create();
/**
* Adds a visual part to this window.
* Supports reparenting.
*/
void Add(LayoutPart::Pointer part);
bool BelongsToWorkbenchPage(IWorkbenchPage::Pointer workbenchPage);
bool Close();
/*
- * @see org.blueberry.ui.internal.IDragOverListener#Drag(void*, Object::Pointer, const QPoint&, const QRect& )
+ * @see org.blueberry.ui.internal.IDragOverListener#Drag(QWidget*, Object::Pointer, const QPoint&, const QRect& )
*/
- IDropTarget::Pointer Drag(void* currentControl,
+ IDropTarget::Pointer Drag(QWidget* currentControl,
const Object::Pointer& draggedObject, const QPoint& position,
const QRect& dragRectangle);
ILayoutContainer::ChildrenType GetChildren() const;
WorkbenchPage::Pointer GetWorkbenchPage();
/**
* @see IPersistablePart
*/
void RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
void SaveState(IMemento::Pointer memento);
- void* GetControl();
+ QWidget* GetControl();
/**
* Opens the detached window.
*/
int Open();
protected:
void ActivePartChanged(IWorkbenchPartReference::Pointer partReference);
/**
* This method will be called to initialize the given Shell's layout
*/
void ConfigureShell(Shell::Pointer shell);
/**
* Override this method to create the widget tree that is used as the window's contents.
*/
- void* CreateContents(void* parent);
+ QWidget* CreateContents(QWidget* parent);
private:
void UpdateTitle();
/**
* Ensure that the shell's minimum size is equal to the minimum size
* of the first part added to the shell.
*/
void UpdateMinimumSize();
static IWorkbenchPartReference::Pointer GetPartReference(
LayoutPart::Pointer pane);
/**
* Closes this window and disposes its shell.
*/
bool HandleClose();
/**
* Prompts for and handles the saving of dirty, saveable views
* @param views The list of ViewPanes
* @return true
unless the user cancels the save(s)
*/
bool HandleSaves(QList views);
/**
* Answer a list of the view panes.
*/
void CollectViewPanes(QList& result,
const QList& parts);
};
}
#endif /* BERRYDETACHEDWINDOW_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
index 5b8cb5afa9..edd2b9ddcd 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.cpp
@@ -1,361 +1,293 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryDragUtil.h"
#include "berryGeometry.h"
#include "berryQtTracker.h"
namespace berry
{
const QString DragUtil::DROP_TARGET_ID =
"org.blueberry.ui.internal.dropTarget";
TestDropLocation::Pointer DragUtil::forcedDropTarget(0);
QList DragUtil::defaultTargets = QList();
-DragUtil::TrackerMoveListener::TrackerMoveListener(Object::Pointer draggedItem,
- const QRect& sourceBounds, const QPoint& initialLocation,
- bool allowSnapping) :
- allowSnapping(allowSnapping), draggedItem(draggedItem), sourceBounds(
- sourceBounds), initialLocation(initialLocation)
-{
-
-}
-
-GuiTk::IControlListener::Events::Types DragUtil::TrackerMoveListener::GetEventTypes() const
-{
- return Events::MOVED;
-}
-
-void DragUtil::TrackerMoveListener::ControlMoved(
- GuiTk::ControlEvent::Pointer event)
-{
-
- // Get the curslor location as a point
- QPoint location(event->x, event->y);
-
- // Select a drop target; use the global one by default
- IDropTarget::Pointer target;
-
- void* targetControl =
- Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
-
- // Get the QtTracker which fired the event
- QtTracker* tracker = static_cast (event->item);
-
- // Get the drop target for this location
- target = DragUtil::GetDropTarget(targetControl, draggedItem, location,
- tracker->GetRectangle());
-
- // Set up the tracker feedback based on the target
- QRect snapTarget;
- if (target != 0)
- {
- snapTarget = target->GetSnapRectangle();
-
- tracker->SetCursor(target->GetCursor());
- }
- else
- {
- tracker->SetCursor(CURSOR_INVALID);
- }
-
- // If snapping then reset the tracker's rectangle based on the current drop target
- if (allowSnapping)
- {
- if (snapTarget.width() < 0 || snapTarget.height() < 0)
- {
- snapTarget = QRect(sourceBounds.x() + location.x() - initialLocation.x(),
- sourceBounds.y() + location.y() - initialLocation.y(), sourceBounds.width(),
- sourceBounds.height());
- }
-
- // Try to prevent flicker: don't change the rectangles if they're already in
- // the right location
- QRect currentRectangle = tracker->GetRectangle();
-
- if (!(currentRectangle == snapTarget))
- {
- tracker->SetRectangle(snapTarget);
- }
- }
-
-}
-DragUtil::TargetListType::Pointer DragUtil::GetTargetList(void* control)
+DragUtil::TargetListType::Pointer DragUtil::GetTargetList(QWidget* control)
{
Object::Pointer data = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetData(
control, DROP_TARGET_ID);
TargetListType::Pointer list = data.Cast ();
return list;
}
IDropTarget::Pointer DragUtil::GetDropTarget(const QList& toSearch,
- void* mostSpecificControl,
+ QWidget* mostSpecificControl,
Object::Pointer draggedObject,
const QPoint& position,
const QRect& dragRectangle)
{
for (QList::const_iterator iter =
toSearch.begin(); iter != toSearch.end(); ++iter)
{
IDragOverListener* next = *iter;
IDropTarget::Pointer dropTarget = next->Drag(mostSpecificControl,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
}
return IDropTarget::Pointer(0);
}
-void DragUtil::AddDragTarget(void* control, IDragOverListener* target)
+void DragUtil::AddDragTarget(QWidget* control, IDragOverListener* target)
{
if (control == 0)
{
defaultTargets.push_back(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList == 0)
{
targetList = new TargetListType();
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control, DROP_TARGET_ID,
targetList);
}
targetList->push_back(target);
}
}
-void DragUtil::RemoveDragTarget(void* control, IDragOverListener* target)
+void DragUtil::RemoveDragTarget(QWidget* control, IDragOverListener* target)
{
if (control == 0)
{
defaultTargets.removeAll(target);
}
else
{
TargetListType::Pointer targetList = GetTargetList(control);
if (targetList != 0)
{
targetList->removeAll(target);
if (targetList->empty())
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetData(control,
DROP_TARGET_ID, Object::Pointer(0));
}
}
}
}
-QRect DragUtil::GetDisplayBounds(void* boundsControl)
+QRect DragUtil::GetDisplayBounds(QWidget* boundsControl)
{
- void* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(
+ QWidget* parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(
boundsControl);
if (parent == 0)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(boundsControl);
}
QRect rect = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(
boundsControl);
return Geometry::ToDisplay(parent, rect);
}
bool DragUtil::PerformDrag(Object::Pointer draggedItem,
const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping)
{
IDropTarget::Pointer target = DragToTarget(draggedItem, sourceBounds,
initialLocation, allowSnapping);
if (target == 0)
{
return false;
}
target->Drop();
target->DragFinished(true);
return true;
}
void DragUtil::ForceDropLocation(TestDropLocation::Pointer forcedLocation)
{
forcedDropTarget = forcedLocation;
}
IDropTarget::Pointer DragUtil::DragToTarget(Object::Pointer draggedItem,
const QRect& sourceBounds, const QPoint& initialLocation,
bool allowSnapping)
{
//final Display display = Display.getCurrent();
// Testing...immediately 'drop' onto the test target
if (forcedDropTarget != 0)
{
QPoint location = forcedDropTarget->GetLocation();
- void* currentControl =
+ QWidget* currentControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->FindControl(
forcedDropTarget->GetShells(), location);
return GetDropTarget(currentControl, draggedItem, location, sourceBounds);
}
// Create a tracker. This is just an XOR rect on the screen.
// As it moves we notify the drag listeners.
QtTracker tracker;
//tracker.setStippled(true);
- GuiTk::IControlListener::Pointer trackerListener(new TrackerMoveListener(
- draggedItem, sourceBounds, initialLocation, allowSnapping));
+ QtTrackerMoveListener trackerListener(draggedItem, sourceBounds,
+ initialLocation, allowSnapping);
- tracker.AddControlListener(trackerListener);
+ trackerListener.connect(&tracker, SIGNAL(Moved(QtTracker*,QPoint)), SLOT(Moved(QtTracker*,QPoint)));
// Setup...when the drag starts we might already be over a valid target, check this...
// If there is a 'global' target then skip the check
IDropTarget::Pointer target;
- void* startControl =
+ QWidget* startControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
if (startControl != 0 && allowSnapping)
{
target = GetDropTarget(startControl, draggedItem, initialLocation,
sourceBounds);
}
// Set up an initial tracker rectangle
QRect startRect = sourceBounds;
if (target != 0)
{
QRect rect = target->GetSnapRectangle();
if (rect.width() != 0 && rect.height() != 0)
{
startRect = rect;
}
tracker.SetCursor(target->GetCursor());
}
if (startRect.width() != 0 && startRect.height() != 0)
{
tracker.SetRectangle(startRect);
}
// Tracking Loop...tracking is preformed on the 'SWT.Move' listener registered
// against the tracker.
// // HACK:
// // Some control needs to capture the mouse during the drag or other
// // controls will interfere with the cursor
// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
// if (shell != null)
// {
// shell.setCapture(true);
// }
// Run tracker until mouse up occurs or escape key pressed.
bool trackingOk = tracker.Open();
// // HACK:
// // Release the mouse now
// if (shell != null)
// {
// shell.setCapture(false);
// }
// Done tracking...
// Get the current drop target
IDropTarget::Pointer dropTarget;
QPoint finalLocation =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorLocation();
- void* targetControl =
+ QWidget* targetControl =
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetCursorControl();
dropTarget = GetDropTarget(targetControl, draggedItem, finalLocation,
tracker.GetRectangle());
// Cleanup...
//delete tracker;
// if we're going to perform a 'drop' then delay the issuing of the 'finished'
// callback until after it's done...
if (trackingOk)
{
return dropTarget;
}
else if (dropTarget != 0)
{
// If the target can handle a 'finished' notification then send one
dropTarget->DragFinished(false);
}
return IDropTarget::Pointer(0);
}
-IDropTarget::Pointer DragUtil::GetDropTarget(void* toSearch,
+IDropTarget::Pointer DragUtil::GetDropTarget(QWidget* toSearch,
Object::Pointer draggedObject, const QPoint& position,
const QRect& dragRectangle)
{
// Search for a listener by walking the control's parent hierarchy
- for (void* current = toSearch; current != 0; current = Tweaklets::Get(
+ for (QWidget* current = toSearch; current != 0; current = Tweaklets::Get(
GuiWidgetsTweaklet::KEY)->GetParent(current))
{
TargetListType::Pointer targetList = GetTargetList(current);
QList targets;
if (targetList != 0)
targets = *targetList;
IDropTarget::Pointer dropTarget = GetDropTarget(targets, toSearch,
draggedObject, position, dragRectangle);
if (dropTarget != 0)
{
return dropTarget;
}
// // Don't look to parent shells for drop targets
// if (current instanceof Shell) {
// break;
// }
}
// No controls could handle this event -- check for default targets
return GetDropTarget(defaultTargets, toSearch, draggedObject, position,
dragRectangle);
}
//QPoint DragUtil::GetEventLoc(GuiTk::ControlEvent::Pointer event)
//{
// Control ctrl = (Control) event.widget;
// return ctrl.toDisplay(new QPoint(event.x, event.y));
//}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
index 4df7ba7b62..5f80e52cee 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryDragUtil.h
@@ -1,215 +1,203 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYDRAGUTIL_H_
#define BERRYDRAGUTIL_H_
#include
#include "guitk/berryGuiTkIControlListener.h"
#include "berryTestDropLocation.h"
#include "berryIDragOverListener.h"
#include "berryIDropTarget.h"
#include
#include
#include
namespace berry {
/**
- * Provides the methods for attaching drag-and-drop listeners to SWT controls.
+ * Provides the methods for attaching drag-and-drop listeners to controls.
*/
class BERRY_UI_QT DragUtil
{
public:
typedef ObjectList TargetListType;
private:
static const QString DROP_TARGET_ID;
- /**
- * The location where all drags will end. If this is non-null, then
- * all user input is ignored in drag/drop. If null, we use user input
- * to determine where objects should be dropped.
- */
- static TestDropLocation::Pointer forcedDropTarget;
-
- /**
- * List of IDragOverListener
- */
- static QList defaultTargets;
-
- /**
- * Return the list of 'IDragOverListener' elements associated with
- * the given control. If there's a 'global' listener then always
- * return it.
- *
- * @param control
- * @return
- */
- static TargetListType::Pointer GetTargetList(void* control);
-
- /**
- * Given a list of IDragOverListeners and a description of what is being dragged, it returns
- * a IDropTarget for the current drop.
- *
- * @param toSearch
- * @param mostSpecificControl
- * @param draggedObject
- * @param position
- * @param dragRectangle
- * @return
- */
- static IDropTarget::Pointer GetDropTarget(const QList& toSearch,
- void* mostSpecificControl, Object::Pointer draggedObject, const QPoint &position,
- const QRect& dragRectangle);
-
-
- struct TrackerMoveListener : public GuiTk::IControlListener {
-
- TrackerMoveListener(Object::Pointer draggedItem, const QRect& sourceBounds,
- const QPoint& initialLocation, bool allowSnapping);
-
- Events::Types GetEventTypes() const;
-
- void ControlMoved(GuiTk::ControlEvent::Pointer event);
-
- private:
-
- bool allowSnapping;
- Object::Pointer draggedItem;
- QRect sourceBounds;
- QPoint initialLocation;
- };
+ /**
+ * The location where all drags will end. If this is non-null, then
+ * all user input is ignored in drag/drop. If null, we use user input
+ * to determine where objects should be dropped.
+ */
+ static TestDropLocation::Pointer forcedDropTarget;
+ /**
+ * List of IDragOverListener
+ */
+ static QList defaultTargets;
+
+ /**
+ * Return the list of 'IDragOverListener' elements associated with
+ * the given control. If there's a 'global' listener then always
+ * return it.
+ *
+ * @param control
+ * @return
+ */
+ static TargetListType::Pointer GetTargetList(QWidget* control);
+
+ /**
+ * Given a list of IDragOverListeners and a description of what is being dragged, it returns
+ * a IDropTarget for the current drop.
+ *
+ * @param toSearch
+ * @param mostSpecificControl
+ * @param draggedObject
+ * @param position
+ * @param dragRectangle
+ * @return
+ */
+ static IDropTarget::Pointer GetDropTarget(const QList& toSearch,
+ QWidget* mostSpecificControl,
+ Object::Pointer draggedObject,
+ const QPoint &position,
+ const QRect& dragRectangle);
public:
- /**
- * Sets the drop target for the given control. It is possible to add one or more
- * targets for a "null" control. This becomes a default target that is used if no
- * other targets are found (for example, when dragging objects off the application
- * window).
- *
- * @param control the control that should be treated as a drag target, or null
- * to indicate the default target
- * @param target the drag target to handle the given control
- */
- static void AddDragTarget(void* control, IDragOverListener* target);
-
- /**
- * Removes a drop target from the given control.
- *
- * @param control
- * @param target
- */
- static void RemoveDragTarget(void* control, IDragOverListener* target);
-
- /**
- * Shorthand method. Returns the bounding rectangle for the given control, in
- * display coordinates.
- *
- * @param draggedItem
- * @param boundsControl
- * @return
- */
- static QRect GetDisplayBounds(void* boundsControl);
+ /**
+ * Sets the drop target for the given control. It is possible to add one or more
+ * targets for a "null" control. This becomes a default target that is used if no
+ * other targets are found (for example, when dragging objects off the application
+ * window).
+ *
+ * @param control the control that should be treated as a drag target, or null
+ * to indicate the default target
+ * @param target the drag target to handle the given control
+ */
+ static void AddDragTarget(QWidget* control, IDragOverListener* target);
+
+ /**
+ * Removes a drop target from the given control.
+ *
+ * @param control
+ * @param target
+ */
+ static void RemoveDragTarget(QWidget* control, IDragOverListener* target);
+
+ /**
+ * Shorthand method. Returns the bounding rectangle for the given control, in
+ * display coordinates.
+ *
+ * @param draggedItem
+ * @param boundsControl
+ * @return
+ */
+ static QRect GetDisplayBounds(QWidget* boundsControl);
static bool PerformDrag(Object::Pointer draggedItem,
- const QRect& sourceBounds, const QPoint& initialLocation, bool allowSnapping);
+ const QRect& sourceBounds,
+ const QPoint& initialLocation,
+ bool allowSnapping);
// /**
// * Drags the given item to the given location (in display coordinates). This
// * method is intended for use by test suites.
// *
// * @param draggedItem object being dragged
// * @param finalLocation location being dragged to
// * @return true iff the drop was accepted
// */
// static bool DragTo(Display display, Object draggedItem,
// QPoint finalLocation, QRect dragRectangle) {
// Control currentControl = SwtUtil.findControl(display, finalLocation);
//
// IDropTarget target = getDropTarget(currentControl, draggedItem,
// finalLocation, dragRectangle);
//
// if (target == null) {
// return false;
// }
//
// target.drop();
//
// return true;
// }
/**
* Forces all drags to end at the given position (display coordinates). Intended
* for use by test suites. If this method is called, then all subsequent calls
* to performDrag will terminate immediately and behave as though the object were
* dragged to the given location. Calling this method with null cancels this
* behavior and causes performDrag to behave normally.
*
* @param forcedLocation location where objects will be dropped (or null to
* cause drag/drop to behave normally).
*/
static void ForceDropLocation(TestDropLocation::Pointer forcedLocation);
/**
* Drags the given item, given an initial bounding rectangle in display coordinates.
* Due to a quirk in the Tracker class, changing the tracking rectangle when using the
* keyboard will also cause the mouse cursor to move. Since "snapping" causes the tracking
* rectangle to change based on the position of the mouse cursor, it is impossible to do
* drag-and-drop with the keyboard when snapping is enabled.
*
* @param draggedItem object being dragged
* @param sourceBounds initial bounding rectangle for the dragged item
* @param initialLocation initial position of the mouse cursor
* @param allowSnapping true iff the rectangle should snap to the drop location. This must
* be false if the user might be doing drag-and-drop using the keyboard.
*
* @return
*/
static IDropTarget::Pointer DragToTarget(Object::Pointer draggedItem,
- const QRect& sourceBounds, const QPoint& initialLocation,
- bool allowSnapping);
+ const QRect& sourceBounds,
+ const QPoint& initialLocation,
+ bool allowSnapping);
/**
* Returns the drag target for the given control or null if none.
*
* @param toSearch
* @param e
* @return
*/
- static IDropTarget::Pointer GetDropTarget(void* toSearch,
- Object::Pointer draggedObject, const QPoint& position, const QRect& dragRectangle);
+ static IDropTarget::Pointer GetDropTarget(QWidget* toSearch,
+ Object::Pointer draggedObject,
+ const QPoint& position,
+ const QRect& dragRectangle);
/**
* Returns the location of the given event, in display coordinates
* @return
*/
//static QPoint GetEventLoc(GuiTk::ControlEvent::Pointer event);
};
}
#endif /* BERRYDRAGUTIL_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
index 9ff0db04d8..e3e4eeb709 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.cpp
@@ -1,609 +1,609 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryEditorSashContainer.h"
#include "berryPresentationSerializer.h"
#include "berryWorkbenchConstants.h"
#include "berryWorkbenchPlugin.h"
#include "berryLayoutTree.h"
#include "berryWorkbenchWindowConfigurer.h"
#include "berryWorkbenchWindow.h"
#include "berryQtDnDControlWidget.h"
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include
#include
namespace berry
{
const QString EditorSashContainer::DEFAULT_WORKBOOK_ID =
"DefaultEditorWorkbook";
void EditorSashContainer::AddChild(const RelationshipInfo& info)
{
PartSashContainer::AddChild(info);
this->UpdateStackButtons();
}
void EditorSashContainer::ChildAdded(LayoutPart::Pointer child)
{
PartSashContainer::ChildAdded(child);
if (child.Cast () != 0)
{
editorWorkbooks.push_back(child.Cast ());
}
}
void EditorSashContainer::ChildRemoved(LayoutPart::Pointer child)
{
PartSashContainer::ChildRemoved(child);
if (child.Cast () != 0)
{
editorWorkbooks.removeAll(child.Cast());
if (activeEditorWorkbook == child)
{
this->SetActiveWorkbook(PartStack::Pointer(0), false);
}
this->UpdateStackButtons();
}
}
PartStack::Pointer EditorSashContainer::CreateDefaultWorkbook()
{
PartStack::Pointer newWorkbook = this->NewEditorWorkbook();
newWorkbook->SetID(DEFAULT_WORKBOOK_ID);
this->Add(newWorkbook);
return newWorkbook;
}
void EditorSashContainer::AddDropSupport()
{
WorkbenchWindowConfigurer::Pointer winConfigurer = page->GetWorkbenchWindow().Cast()->GetWindowConfigurer();
QtDnDControlWidget* dropWidget = static_cast(GetParent());
dropWidget->SetTransferTypes(winConfigurer->GetTransfers());
dropWidget->AddDropListener(winConfigurer->GetDropTargetListener());
}
PartStack::Pointer EditorSashContainer::NewEditorWorkbook()
{
PartStack::Pointer newWorkbook(new PartStack(page, true, PresentationFactoryUtil::ROLE_EDITOR));
QString str;
QTextStream buf(&str);
buf << newWorkbook->GetClassName() << newWorkbook.GetPointer();
newWorkbook->SetID(str);
return newWorkbook;
}
-void* EditorSashContainer::CreateParent(void* parentWidget)
+QWidget* EditorSashContainer::CreateParent(QWidget* parentWidget)
{
//return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget);
return new QtDnDControlWidget(static_cast(parentWidget));
}
void EditorSashContainer::DisposeParent()
{
this->parent = 0;
}
bool EditorSashContainer::IsActiveWorkbook(PartStack::Pointer workbook)
{
return activeEditorWorkbook == workbook;
}
PartStack::Pointer EditorSashContainer::CreateStack()
{
return this->NewEditorWorkbook();
}
void EditorSashContainer::SetVisiblePart(
ILayoutContainer::Pointer container, PartPane::Pointer visiblePart)
{
PartStack::Pointer stack = container.Cast();
if (stack == 0) return;
stack->GetContainer().Cast()->SetActiveWorkbook(stack, true);
stack->SetSelection(visiblePart);
}
LayoutPart::Pointer EditorSashContainer::GetVisiblePart(
ILayoutContainer::Pointer container)
{
PartStack::Pointer refPart = container.Cast();
return refPart->GetSelection();
}
EditorSashContainer::EditorSashContainer(const QString& editorId,
- WorkbenchPage* page, void* parent)
+ WorkbenchPage* page, QWidget* parent)
: PartSashContainer(editorId, page, parent)
{
this->CreateDefaultWorkbook();
}
bool EditorSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart)
{
return LayoutPart::AllowsAdd(layoutPart);
}
void EditorSashContainer::AddEditor(PartPane::Pointer pane,
PartStack::Pointer stack)
{
//EditorStack workbook = getActiveWorkbook();
stack->Add(pane);
}
void EditorSashContainer::UpdateStackButtons()
{
// // This is applicable only when the new
// // min/max behaviour is being used
// Perspective persp = getPage().getActivePerspective();
// if (!Perspective.useNewMinMax(persp))
// return;
//
// // Find the upper Right editor stack
// LayoutPart[] stacks = getChildren();
// EditorStack winner = getUpperRightEditorStack(stacks);
//
// // Now hide the buttons for all but the upper right stack
// for (int i = 0; i < stacks.length; i++)
// {
// if (!(stacks[i] instanceof EditorStack)
// )
// continue;
// ((EditorStack) stacks[i]).showMinMax(stacks[i] == winner);
// }
//
// // Force the stack's presentation state to match its perspective
// persp.refreshEditorAreaVisibility();
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack()
{
return this->GetUpperRightEditorStack(this->GetChildren());
}
PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks)
{
// Find the upper Right editor stack
PartStack::Pointer winner;
QRect winnerRect;
for (ILayoutContainer::ChildrenType::const_iterator iter = stacks.begin();
iter != stacks.end(); ++iter)
{
LayoutPart::Pointer part = *iter;
if (part.Cast() == 0)
continue;
PartStack::Pointer stack = part.Cast();
QRect bb = stack->GetBounds();
if (iter == stacks.begin() || bb.y() < winnerRect.y() || (bb.y() == winnerRect.y() && bb.x()
> winnerRect.x()))
{
winner = stack;
winnerRect = bb;
}
}
return winner;
}
PartStack::Pointer EditorSashContainer::GetActiveWorkbook()
{
if (activeEditorWorkbook == 0)
{
if (editorWorkbooks.size() < 1)
{
this->SetActiveWorkbook(this->CreateDefaultWorkbook(), false);
}
else
{
this->SetActiveWorkbook(editorWorkbooks.front(), false);
}
}
return activeEditorWorkbook;
}
QString EditorSashContainer::GetActiveWorkbookID()
{
return this->GetActiveWorkbook()->GetID();
}
QList EditorSashContainer::GetEditorWorkbooks()
{
return editorWorkbooks;
}
std::size_t EditorSashContainer::GetEditorWorkbookCount()
{
return editorWorkbooks.size();
}
void EditorSashContainer::FindSashes(LayoutPart::Pointer pane,
PartPane::Sashes& sashes)
{
//Find the sashes around the current editor and
//then the sashes around the editor area.
PartSashContainer::FindSashes(pane, sashes);
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->FindSashes(LayoutPart::Pointer(this), sashes);
}
}
void EditorSashContainer::RemoveAllEditors()
{
PartStack::Pointer currentWorkbook = this->GetActiveWorkbook();
// Iterate over a copy so the original can be modified.
QList workbooks(editorWorkbooks);
for (QList::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
QList children = workbook->GetChildren();
for (QList::iterator childIter = children.begin();
childIter != children.end(); ++childIter)
{
workbook->Remove(*childIter);
}
if (workbook != currentWorkbook)
{
this->Remove(workbook);
workbook->Dispose();
}
}
}
void EditorSashContainer::RemoveEditor(PartPane::Pointer pane)
{
PartStack::Pointer workbook = pane->GetContainer().Cast();
if (workbook == 0)
{
return;
}
workbook->Remove(pane);
// remove the editor workbook if empty
if (workbook->GetItemCount() < 1 /* && editorWorkbooks.size() > 1*/)
{
// // If the user closes the last editor and the editor area
// // is maximized, restore it
// Perspective persp = getPage().getActivePerspective();
// if (Perspective.useNewMinMax(persp))
// {
// if (persp.getPresentation().getMaximizedStack() instanceof EditorStack)
// persp.getPresentation().getMaximizedStack().
// setState(IStackPresentationSite.STATE_RESTORED);
// }
this->Remove(workbook);
workbook->Dispose();
}
}
bool EditorSashContainer::RestoreState(IMemento::Pointer memento)
{
//TODO EditorSashContainer restore state
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, 0);
bool result = true;
// Remove the default editor workbook that is
// initialy created with the editor area.
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
PartStack::Pointer defaultWorkbook;
for (ILayoutContainer::ChildrenType::iterator i = children.begin();
i != children.end(); ++i)
{
LayoutPart::Pointer child = *i;
if (child->GetID() == DEFAULT_WORKBOOK_ID)
{
defaultWorkbook = child.Cast();
if (defaultWorkbook->GetItemCount() > 0)
{
defaultWorkbook = 0;
}
}
}
if (defaultWorkbook)
{
Remove(defaultWorkbook);
}
// }}
// );
// Restore the relationship/layout
QList infos(memento->GetChildren(WorkbenchConstants::TAG_INFO));
QHash mapIDtoPart;
for (int i = 0; i < infos.size(); i++)
{
// Get the info details.
IMemento::Pointer childMem = infos[i];
QString partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID);
QString relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID);
int relationship = 0;
int left = 0, right = 0;
if (!relativeID.isEmpty())
{
childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left);
childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right);
}
PartStack::Pointer workbook;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Create the part.
workbook = NewEditorWorkbook();
workbook->SetID(partID);
// 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
workbook->SetContainer(ILayoutContainer::Pointer(this));
// }}
// );
IMemento::Pointer workbookMemento = childMem->GetChild(
WorkbenchConstants::TAG_FOLDER);
if (workbookMemento)
{
//result.add(workbook[0].restoreState(workbookMemento));
result &= workbook->RestoreState(workbookMemento);
}
const int myLeft = left, myRight = right, myRelationship = relationship;
// StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
//
// public void runWithException() throws Throwable
// {
// Add the part to the layout
if (relativeID.isEmpty())
{
Add(workbook);
}
else
{
LayoutPart::Pointer refPart = mapIDtoPart[relativeID];
if (refPart)
{
Add(workbook, myRelationship, myLeft, myRight, refPart);
}
else
{
WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID);
}
}
// }}
// );
mapIDtoPart[partID] = workbook;
}
return result;
}
bool EditorSashContainer::SaveState(IMemento::Pointer memento)
{
QList relationships(ComputeRelation());
// MultiStatus
// result =
// new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, 0);
bool result = true;
for (int i = 0; i < relationships.size(); i++)
{
// Save the relationship info ..
// private LayoutPart part;
// private int relationship;
// private float ratio;
// private LayoutPart relative;
const RelationshipInfo& info = relationships[i];
IMemento::Pointer childMem = memento->CreateChild(
WorkbenchConstants::TAG_INFO);
childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID());
PartStack::Pointer stack = info.part.Cast();
if (stack)
{
IMemento::Pointer folderMem = childMem->CreateChild(
WorkbenchConstants::TAG_FOLDER);
//result.add(stack.saveState(folderMem));
result &= stack->SaveState(folderMem);
}
if (info.relative != 0)
{
childMem->PutString(WorkbenchConstants::TAG_RELATIVE, info.relative->GetID());
childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP, info.relationship);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left);
childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right);
}
}
return result;
}
void EditorSashContainer::SetActiveWorkbook(PartStack::Pointer newWorkbook,
bool hasFocus)
{
if (newWorkbook != 0)
{
if (std::find(editorWorkbooks.begin(), editorWorkbooks.end(), newWorkbook) == editorWorkbooks.end())
{
return;
}
}
PartStack::Pointer oldWorkbook = activeEditorWorkbook;
activeEditorWorkbook = newWorkbook;
if (oldWorkbook != 0 && oldWorkbook != newWorkbook)
{
oldWorkbook->SetActive(StackPresentation::AS_INACTIVE);
}
if (newWorkbook != 0)
{
if (hasFocus)
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
else
{
newWorkbook->SetActive(StackPresentation::AS_ACTIVE_NOFOCUS);
}
}
this->UpdateTabList();
}
void EditorSashContainer::SetActiveWorkbookFromID(const QString& id)
{
for (QList::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
this->SetActiveWorkbook(workbook, false);
}
}
}
PartStack::Pointer EditorSashContainer::GetWorkbookFromID(const QString& id)
{
for (QList::iterator iter = editorWorkbooks.begin();
iter != editorWorkbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
if (workbook->GetID() == id)
{
return workbook;
}
}
return PartStack::Pointer(0);
}
void EditorSashContainer::UpdateTabList()
{
- void* parent = this->GetParent();
+ QWidget* parent = this->GetParent();
if (parent != 0)
{ // parent may be 0 on startup
PartStack::Pointer wb(this->GetActiveWorkbook());
//TODO EditorSashContainer update tab list
// if (wb == 0)
// {
// parent.setTabList(new Control[0]);
// }
// else
// {
// parent.setTabList(wb.getTabList());
// }
}
}
-void EditorSashContainer::CreateControl(void* parent)
+void EditorSashContainer::CreateControl(QWidget* parent)
{
PartSashContainer::CreateControl(parent);
///let the user drop files/editor input on the editor area
this->AddDropSupport();
}
bool EditorSashContainer::IsCompressible()
{
//Added for bug 19524
return true;
}
bool EditorSashContainer::IsStackType(ILayoutContainer::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetAppearance()
== PresentationFactoryUtil::ROLE_EDITOR);
}
bool EditorSashContainer::IsPaneType(LayoutPart::Pointer toTest)
{
if (toTest.Cast() == 0)
return false;
return (toTest.Cast ()->GetPartReference().Cast ()
!= 0);
}
bool EditorSashContainer::RestorePresentationState(IMemento::Pointer /*areaMem*/)
{
QList workbooks = this->GetEditorWorkbooks();
for (QList::iterator iter = workbooks.begin();
iter != workbooks.end(); ++iter)
{
PartStack::Pointer workbook = *iter;
IMemento::Pointer memento = workbook->GetSavedPresentationState();
if (memento == 0)
{
continue;
}
QList parts = workbook->GetPresentableParts();
PresentationSerializer serializer(parts);
//StartupThreading.runWithoutExceptions(new StartupRunnable()
// {
// public void runWithException() throws Throwable
// {
workbook->GetPresentation()->RestoreState(&serializer, memento);
// }}
// );
}
//return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$
return true;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.h
index dc2a0c5ca3..ef30614c61 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryEditorSashContainer.h
@@ -1,253 +1,253 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYEDITORSASHCONTAINER_H_
#define BERRYEDITORSASHCONTAINER_H_
#include "berryPartSashContainer.h"
#include "berryPartStack.h"
#include
namespace berry
{
/**
* Represents the area set aside for editor workbooks.
* This container only accepts editor stacks (PartStack) and PartSash
* as layout parts.
*
* Note no views are allowed within this container.
*/
class EditorSashContainer: public PartSashContainer
{
public:
berryObjectMacro(EditorSashContainer)
private:
QList editorWorkbooks;
PartStack::Pointer activeEditorWorkbook;
// DropTarget dropTarget;
void AddDropSupport();
PartStack::Pointer NewEditorWorkbook();
protected:
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#addChild(org.blueberry.ui.internal.PartSashContainer.RelationshipInfo)
*/
void AddChild(const RelationshipInfo& info);
/**
* Notification that a child layout part has been
* added to the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildAdded(LayoutPart::Pointer child);
/**
* Notification that a child layout part has been
* removed from the container. Subclasses may override
* this method to perform any container specific
* work.
*/
void ChildRemoved(LayoutPart::Pointer child);
PartStack::Pointer CreateDefaultWorkbook();
/**
* Subclasses override this method to specify
* the composite to use to parent all children
* layout parts it contains.
*/
- void* CreateParent(void* parentWidget);
+ QWidget* CreateParent(QWidget* parentWidget);
/**
* Subclasses override this method to dispose
* of any swt resources created during createParent.
*/
void DisposeParent();
/**
* Return true is the workbook specified
* is the active one.
*/
bool IsActiveWorkbook(PartStack::Pointer workbook);
//TODO DND
// /* package */DropTarget getDropTarget() {
// return dropTarget;
// }
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#createStack(org.blueberry.ui.internal.LayoutPart)
*/
PartStack::Pointer CreateStack();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#setVisiblePart(org.blueberry.ui.internal.ILayoutContainer, org.blueberry.ui.internal.LayoutPart)
*/
void SetVisiblePart(ILayoutContainer::Pointer container,
PartPane::Pointer visiblePart);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#getVisiblePart(org.blueberry.ui.internal.ILayoutContainer)
*/
LayoutPart::Pointer GetVisiblePart(ILayoutContainer::Pointer container);
public:
static const QString DEFAULT_WORKBOOK_ID;
EditorSashContainer(const QString& editorId, WorkbenchPage* page,
- void* parent);
+ QWidget* parent);
bool AllowsAdd(LayoutPart::Pointer layoutPart);
/**
* Add an editor to the active workbook.
*/
void AddEditor(PartPane::Pointer pane, PartStack::Pointer stack);
/**
* Hides the min/max buttons for all editor stacks
* -except- for the upper/left one.
*/
void UpdateStackButtons();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack();
/**
* @param stacks
* @return the EditorStack in the upper right position
*/
PartStack::Pointer GetUpperRightEditorStack(
const ILayoutContainer::ChildrenType& stacks);
/**
* Return the editor workbook which is active.
*/
PartStack::Pointer GetActiveWorkbook();
/**
* Return the editor workbook id which is active.
*/
QString GetActiveWorkbookID();
/**
* Return the all the editor workbooks.
*/
QList GetEditorWorkbooks();
/**
* Return the all the editor workbooks.
*/
std::size_t GetEditorWorkbookCount();
/**
* Find the sashes around the specified part.
*/
void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes);
/**
* Remove all the editors
*/
void RemoveAllEditors();
/**
* Remove an editor from its' workbook.
*/
void RemoveEditor(PartPane::Pointer pane);
/**
* @see IPersistablePart
*/
bool RestoreState(IMemento::Pointer memento);
/**
* @see IPersistablePart
*/
bool SaveState(IMemento::Pointer memento);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbook(PartStack::Pointer newWorkbook, bool hasFocus);
/**
* Set the editor workbook which is active.
*/
void SetActiveWorkbookFromID(const QString& id);
PartStack::Pointer GetWorkbookFromID(const QString& id);
/**
* Updates the editor area's tab list to include the active
* editor and its tab.
*/
void UpdateTabList();
/**
* @see org.blueberry.ui.internal.LayoutPart#createControl(org.blueberry.swt.widgets.Composite)
*/
- void CreateControl(void* parent);
+ void CreateControl(QWidget* parent);
/**
* @see org.blueberry.ui.internal.LayoutPart#getImportance()
*/
bool IsCompressible();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isStackType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsStackType(ILayoutContainer::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#isPaneType(org.blueberry.ui.internal.LayoutPart)
*/
bool IsPaneType(LayoutPart::Pointer toTest);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.PartSashContainer#pickPartToZoom()
*/
// LayoutPart pickPartToZoom() {
// return getActiveWorkbook();
// }
/**
* Restore the presentation state. Loop over the workbooks, create the appropriate serializer and pass to the presentation.
*
* @param areaMem the memento containing presentation
* @return the restoration status
*/
bool RestorePresentationState(IMemento::Pointer areaMem);
};
}
#endif /* BERRYEDITORSASHCONTAINER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.cpp
index 5e557cdbd2..75cf082157 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.cpp
@@ -1,50 +1,50 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryErrorViewPart.h"
namespace berry
{
ErrorViewPart::ErrorViewPart()
{
}
ErrorViewPart::ErrorViewPart(const QString& title, const QString& error) :
title(title), error(error)
{
}
-void ErrorViewPart::CreatePartControl(void* parent)
+void ErrorViewPart::CreatePartControl(QWidget* parent)
{
if (!error.isEmpty())
{
statusPart = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateStatusPart(
parent, title, error);
}
}
void ErrorViewPart::SetPartName(const QString& newName)
{
ViewPart::SetPartName(newName);
}
void ErrorViewPart::SetFocus()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.h
index a9b5aa5660..65cce6f8c2 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryErrorViewPart.h
@@ -1,82 +1,80 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYERRORVIEWPART_H_
#define BERRYERRORVIEWPART_H_
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryViewPart.h"
namespace berry {
/**
* This part is shown instead the views with errors.
- *
- * @since 3.3
*/
class ErrorViewPart : public ViewPart {
public:
- berryObjectMacro(ErrorViewPart);
+ berryObjectMacro(ErrorViewPart)
/**
* Creates instance of the class
*/
ErrorViewPart();
/**
* Creates instance of the class
*
* @param error the status
*/
ErrorViewPart(const QString& title, const QString& error);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
- void CreatePartControl(void* parent);
+ void CreatePartControl(QWidget* parent);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.ViewPart#setPartName(java.lang.String)
*/
void SetPartName(const QString& newName);
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#setFocus()
*/
void SetFocus();
private:
//IStatus error;
QString title;
QString error;
Object::Pointer statusPart;
};
}
#endif /* BERRYERRORVIEWPART_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
index 9e5ddeea3e..b538d9a5a9 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryIDragOverListener.h
@@ -1,65 +1,65 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYIDRAGOVERLISTENER_H_
#define BERRYIDRAGOVERLISTENER_H_
#include
#include "berryObject.h"
#include "berryIDropTarget.h"
namespace berry {
/**
* Implementers of this interface will receive notifications when objects are dragged over
* a particular control.
*/
struct IDragOverListener
{
struct Events {
- typedef Message4 DragEventType;
- typedef MessageDelegate4 DragDelegate;
+ typedef Message4 DragEventType;
+ typedef MessageDelegate4 DragDelegate;
DragEventType drag;
void AddListener(IDragOverListener* listener);
void RemoveListener(IDragOverListener* listener);
};
virtual ~IDragOverListener();
/**
* Notifies the receiver that the given object has been dragged over
* the given position. Returns a drop target if the object may be
* dropped in this position. Returns null otherwise.
*
* @param draggedObject object being dragged over this location
* @param position location of the cursor
* @param dragRectangle current drag rectangle (may be an empty rectangle if none)
* @return a valid drop target or null if none
*/
- virtual IDropTarget::Pointer Drag(void* currentControl, const Object::Pointer& draggedObject,
+ virtual IDropTarget::Pointer Drag(QWidget* currentControl, const Object::Pointer& draggedObject,
const QPoint& position, const QRect& dragRectangle) = 0;
};
}
#endif /* BERRYIDRAGOVERLISTENER_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
index cfbb0c9b37..871130f09b 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.cpp
@@ -1,345 +1,345 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryLayoutPart.h"
#include "berryILayoutContainer.h"
#include "berryDetachedWindow.h"
#include "berryIWorkbenchWindow.h"
#include "berryConstants.h"
namespace berry
{
const QString LayoutPart::PROP_VISIBILITY = "PROP_VISIBILITY";
LayoutPart::LayoutPart(const QString& id_)
: container(0), id(id_), deferCount(0)
{
}
LayoutPart::~LayoutPart()
{
}
bool LayoutPart::AllowsAutoFocus()
{
if (container != 0)
{
return container->AllowsAutoFocus();
}
return true;
}
void LayoutPart::Dispose()
{
}
QRect LayoutPart::GetBounds()
{
if (this->GetControl() == 0)
return QRect();
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(this->GetControl());
}
ILayoutContainer::Pointer LayoutPart::GetContainer()
{
return ILayoutContainer::Pointer(container);
}
bool LayoutPart::IsPlaceHolder() const
{
return false;
}
QString LayoutPart::GetID() const
{
return id;
}
bool LayoutPart::IsCompressible()
{
return false;
}
QSize LayoutPart::GetSize()
{
return this->GetBounds().size();
}
int LayoutPart::GetSizeFlags(bool /*horizontal*/)
{
return Constants::MIN;
}
int LayoutPart::ComputePreferredSize(bool /*width*/, int /*availableParallel*/,
int /*availablePerpendicular*/, int preferredParallel)
{
return preferredParallel;
}
IDropTarget::Pointer LayoutPart::GetDropTarget(Object::Pointer /*draggedObject*/, const QPoint& /*displayCoordinates*/)
{
return IDropTarget::Pointer(0);
}
bool LayoutPart::IsDocked()
{
Shell::Pointer s = this->GetShell();
if (s == 0) {
return false;
}
return s->GetData().Cast() != 0;
}
Shell::Pointer LayoutPart::GetShell()
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShell(ctrl);
}
return Shell::Pointer(0);
}
IWorkbenchWindow::Pointer LayoutPart::GetWorkbenchWindow()
{
Shell::Pointer s = this->GetShell();
if (s == 0)
{
return IWorkbenchWindow::Pointer(0);
}
Object::Pointer data = s->GetData();
if (data.Cast() != 0)
{
return data.Cast();
}
else if (data.Cast() != 0)
{
return data.Cast()->GetWorkbenchPage()->GetWorkbenchWindow();
}
return IWorkbenchWindow::Pointer(0);
}
-void LayoutPart::MoveAbove(void* /*refControl*/)
+void LayoutPart::MoveAbove(QWidget* /*refControl*/)
{
}
-void LayoutPart::Reparent(void* newParent)
+void LayoutPart::Reparent(QWidget* newParent)
{
- void* control = this->GetControl();
+ QWidget* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
bool LayoutPart::GetVisible()
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl);
}
return false;
}
bool LayoutPart::IsVisible()
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->IsVisible(ctrl);
}
return false;
}
void LayoutPart::SetVisible(bool makeVisible)
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (ctrl != 0)
{
if (makeVisible == Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetVisible(ctrl))
{
return;
}
// if (!makeVisible && this->IsFocusAncestor(ctrl))
// {
// // Workaround for Bug 60970 [EditorMgmt] setActive() called on an editor when it does not have focus.
// // Force focus on the shell so that when ctrl is hidden,
// // SWT does not try to send focus elsewhere, which may cause
// // some other part to be activated, which affects the part
// // activation order and can cause flicker.
// ctrl.getShell().forceFocus();
// }
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(ctrl, makeVisible);
}
}
-bool LayoutPart::IsFocusAncestor(void* /*ctrl*/)
+bool LayoutPart::IsFocusAncestor(QWidget* /*ctrl*/)
{
// Control f = ctrl.getDisplay().getFocusControl();
// while (f != null && f != ctrl)
// {
// f = f.getParent();
// }
// return f == ctrl;
return false;
}
void LayoutPart::SetBounds(const QRect& r)
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (ctrl)
{
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(ctrl, r);
}
}
void LayoutPart::SetContainer(ILayoutContainer::Pointer container)
{
this->container = container.GetPointer();
//TODO Zoom
// if (container != 0)
// {
// setZoomed(container.childIsZoomed(this));
// }
}
void LayoutPart::SetFocus()
{
}
void LayoutPart::SetID(const QString& str)
{
id = str;
}
LayoutPart::Pointer LayoutPart::GetPart()
{
return LayoutPart::Pointer(this);
}
void LayoutPart::DeferUpdates(bool shouldDefer)
{
if (shouldDefer)
{
if (deferCount == 0)
{
this->StartDeferringEvents();
}
deferCount++;
}
else
{
if (deferCount> 0)
{
deferCount--;
if (deferCount == 0)
{
this->HandleDeferredEvents();
}
}
}
}
void LayoutPart::StartDeferringEvents()
{
}
void LayoutPart::HandleDeferredEvents()
{
}
bool LayoutPart::IsDeferred()
{
return deferCount> 0;
}
void LayoutPart::DescribeLayout(QString& /*buf*/) const
{
}
QString LayoutPart::GetPlaceHolderId()
{
return this->GetID();
}
void LayoutPart::ResizeChild(LayoutPart::Pointer /*childThatChanged*/)
{
}
void LayoutPart::FlushLayout()
{
ILayoutContainer::Pointer container = this->GetContainer();
if (container != 0)
{
container->ResizeChild(LayoutPart::Pointer(this));
}
}
bool LayoutPart::AllowsAdd(LayoutPart::Pointer /*toAdd*/)
{
return false;
}
QString LayoutPart::ToString() const
{
return "";
}
void LayoutPart::TestInvariants()
{
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
index 86d5c4eb0f..a75cd331c1 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPart.h
@@ -1,303 +1,303 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTPART_H_
#define BERRYLAYOUTPART_H_
#include
#include "berryIDropTarget.h"
#include "berryISizeProvider.h"
#include "berryShell.h"
namespace berry {
struct ILayoutContainer;
struct IWorkbenchWindow;
/**
* \ingroup org_blueberry_ui_internal
*
* A presentation part is used to build the presentation for the
* workbench. Common subclasses are pane and folder.
*/
class LayoutPart : virtual public Object, public virtual ISizeProvider
{
public:
berryObjectMacro(LayoutPart)
protected: ILayoutContainer* container;
protected: QString id;
public: static const QString PROP_VISIBILITY;// = "PROP_VISIBILITY";
/**
* Number of times deferUpdates(true) has been called without a corresponding
* deferUpdates(false)
*/
private: int deferCount;
/**
* PresentationPart constructor comment.
*/
public: LayoutPart(const QString& id);
public: virtual ~LayoutPart();
/**
* When a layout part closes, focus will return to a previously active part.
* This method determines whether this part should be considered for activation
* when another part closes. If a group of parts are all closing at the same time,
* they will all return false from this method while closing to ensure that the
* parent does not activate a part that is in the process of closing. Parts will
* also return false from this method if they are minimized, closed fast views,
* obscured by zoom, etc.
*
* @return true iff the parts in this container may be given focus when the active
* part is closed
*/
public: virtual bool AllowsAutoFocus();
/**
* Creates the GUI control
*/
- public: virtual void CreateControl(void* parent) = 0;
+ public: virtual void CreateControl(QWidget* parent) = 0;
/**
* Disposes the GUI control
*
* This can be used to execute cleanup code or notify listeners
* when a LayoutPart is no longer used, but is still referenced
* by a SmartPointer (instead of putting the code in the LayoutPart
* destructor).
*/
public: virtual void Dispose();
/**
* Gets the presentation bounds.
*/
public: QRect GetBounds();
/**
* Gets the parent for this part.
*
* In general, this is non-null if the object has been added to a container and the
* container's widgetry exists. The exception to this rule is PartPlaceholders
* created when restoring a ViewStack using restoreState, which point to the
* ViewStack even if its widgetry doesn't exist yet. Returns null in the remaining
* cases.
*
*
* TODO: change the semantics of this method to always point to the parent container,
* regardless of whether its widgetry exists. Locate and refactor code that is currently
* depending on the special cases.
*
*/
public: virtual SmartPointer GetContainer();
/**
* Get the part control. This method may return null.
*/
- public: virtual void* GetControl() = 0;
+ public: virtual QWidget* GetControl() = 0;
public: virtual bool IsPlaceHolder() const;
/**
* Gets the ID for this part.
*/
public: virtual QString GetID() const;
public: virtual bool IsCompressible();
/**
* Gets the presentation size.
*/
public: virtual QSize GetSize();
/**
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @since 3.1
*/
public: virtual int GetSizeFlags(bool horizontal);
/**
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
public: virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
public: virtual IDropTarget::Pointer GetDropTarget(Object::Pointer draggedObject, const QPoint& displayCoordinates);
public: bool IsDocked();
public: virtual Shell::Pointer GetShell();
/**
* Returns the workbench window window for a part.
*
* @return the workbench window, or null
if there's no window
* associated with this part.
*/
public: virtual SmartPointer GetWorkbenchWindow();
/**
* Move the control over another one.
*/
- public: virtual void MoveAbove(void* refControl);
+ public: virtual void MoveAbove(QWidget* refControl);
/**
* Reparent a part.
*/
- public: virtual void Reparent(void* newParent);
+ public: virtual void Reparent(QWidget* newParent);
/**
* Returns true if this part was set visible. This returns whatever was last passed into
* setVisible, but does not necessarily indicate that the part can be seen (ie: one of its
* ancestors may be invisible)
*/
public: virtual bool GetVisible();
/**
* Returns true if this part can be seen. Returns false if the part or any of its ancestors
* are invisible.
*/
public: virtual bool IsVisible();
/**
* Shows the receiver if visible
is true otherwise hide it.
*/
public: virtual void SetVisible(bool makeVisible);
/**
* Returns true
if the given control or any of its descendents has focus.
*/
- private: virtual bool IsFocusAncestor(void* ctrl);
+ private: virtual bool IsFocusAncestor(QWidget* ctrl);
/**
* Sets the presentation bounds.
*/
public: virtual void SetBounds(const QRect& r);
/**
* Sets the parent for this part.
*/
public: virtual void SetContainer(SmartPointer container);
/**
* Sets focus to this part.
*/
public: virtual void SetFocus();
/**
* Sets the part ID.
*/
public: virtual void SetID(const QString& str);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.IWorkbenchDragDropPart#getPart()
*/
public: virtual LayoutPart::Pointer GetPart();
/**
* deferUpdates(true) disables widget updates until a corresponding call to
* deferUpdates(false). Exactly what gets deferred is the decision
* of each LayoutPart, however the part may only defer operations in a manner
* that does not affect the final result.
* That is, the state of the receiver after the final call to deferUpdates(false)
* must be exactly the same as it would have been if nothing had been deferred.
*
* @param shouldDefer true iff events should be deferred
*/
public: void DeferUpdates(bool shouldDefer);
/**
* This is called when deferUpdates(true) causes UI events for this
* part to be deferred. Subclasses can overload to initialize any data
* structures that they will use to collect deferred events.
*/
protected: virtual void StartDeferringEvents();
/**
* Immediately processes all UI events which were deferred due to a call to
* deferUpdates(true). This is called when the last call is made to
* deferUpdates(false). Subclasses should overload this method if they
* defer some or all UI processing during deferUpdates.
*/
protected: virtual void HandleDeferredEvents();
/**
* Subclasses can call this method to determine whether UI updates should
* be deferred. Returns true iff there have been any calls to deferUpdates(true)
* without a corresponding call to deferUpdates(false). Any operation which is
* deferred based on the result of this method should be performed later within
* handleDeferredEvents().
*
* @return true iff updates should be deferred.
*/
protected: bool IsDeferred();
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they do not need to be translated.
*
* @param buf
*/
public: virtual void DescribeLayout(QString& buf) const;
/**
* Returns an id representing this part, suitable for use in a placeholder.
*
* @since 3.0
*/
public: virtual QString GetPlaceHolderId();
public: virtual void ResizeChild(LayoutPart::Pointer childThatChanged);
public: void FlushLayout();
/**
* Returns true iff the given part can be added to this ILayoutContainer
* @param toAdd
* @return
* @since 3.1
*/
public: virtual bool AllowsAdd(LayoutPart::Pointer toAdd);
/**
* Tests the integrity of this object. Throws an exception if the object's state
* is not internally consistent. For use in test suites.
*/
public: virtual void TestInvariants();
public: virtual QString ToString() const;
};
}
#endif /*BERRYLAYOUTPART_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
index 82c3ecf95e..8a489fdcfe 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.cpp
@@ -1,306 +1,306 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryLayoutPartSash.h"
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryWorkbenchPlugin.h"
#include "berryConstants.h"
namespace berry
{
LayoutPartSash::SelectionListener::SelectionListener(LayoutPartSash* lp)
: layoutPartSash(lp)
{
}
void LayoutPartSash::SelectionListener::WidgetSelected(GuiTk::SelectionEvent::Pointer e)
{
layoutPartSash->CheckDragLimit(e);
if (e->detail != Constants::DRAG)
{
layoutPartSash->WidgetSelected(e->x, e->y, e->width,
e->height);
}
}
LayoutPartSash::LayoutPartSash(PartSashContainer* rootContainer, int style)
: LayoutPart(""), sash(0), enabled(false), rootContainer(rootContainer),
style(style), left(300), right(300), presFactory(0), isVisible(false)
{
selectionListener = new SelectionListener(this);
}
LayoutPartSash::~LayoutPartSash()
{
this->Dispose();
}
void LayoutPartSash::CheckDragLimit(GuiTk::SelectionEvent::Pointer event)
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
QRect nodeBounds = node->GetBounds();
QRect eventRect(event->x, event->y, event->width, event->height);
bool vertical = (style == Constants::VERTICAL);
// If a horizontal sash, flip the coordinate system so that we
// can handle horizontal and vertical sashes without special cases
if (!vertical)
{
nodeBounds = QRect(nodeBounds.y(), nodeBounds.x(), nodeBounds.height(), nodeBounds.width());
eventRect = QRect(eventRect.y(), eventRect.x(), eventRect.height(), eventRect.width());
}
int eventX = eventRect.x();
int left = std::max(0, eventX - nodeBounds.x());
left = std::min(left, nodeBounds.width() - this->GetSashSize());
int right = nodeBounds.width() - left - this->GetSashSize();
LayoutTreeNode::ChildSizes sizes = node->ComputeChildSizes(nodeBounds.width(), nodeBounds.height(), left, right, nodeBounds.width());
eventRect.setX(nodeBounds.x() + sizes.left);
// If it's a horizontal sash, restore eventRect to its original coordinate system
if (!vertical)
{
eventRect = QRect(eventRect.y(), eventRect.x(), eventRect.height(), eventRect.width());
}
event->x = eventRect.x();
event->y = eventRect.y();
}
-void LayoutPartSash::CreateControl(void* /*parent*/)
+void LayoutPartSash::CreateControl(QWidget* /*parent*/)
{
// Defer creation of the control until it becomes visible
if (isVisible)
{
this->DoCreateControl();
}
}
void LayoutPartSash::DoCreateControl()
{
if (sash == 0)
{
// ask the presentation factory to create the sash
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
sash = factory->CreateSash(this->rootContainer->GetParent(), sashStyle);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddSelectionListener(sash, selectionListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetBounds(sash, bounds);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(sash, isVisible);
}
}
void LayoutPartSash::SetBounds(const QRect& r)
{
LayoutPart::SetBounds(r);
bounds = r;
}
void LayoutPartSash::SetVisible(bool visible)
{
if (visible == isVisible)
{
return;
}
if (visible)
{
this->DoCreateControl();
}
else
{
this->Dispose();
}
LayoutPart::SetVisible(visible);
isVisible = visible;
}
bool LayoutPartSash::IsVisible()
{
return isVisible;
}
void LayoutPartSash::Dispose()
{
if (sash != 0)
{
bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(sash);
}
sash = 0;
}
QRect LayoutPartSash::GetBounds()
{
if (sash == 0)
{
return bounds;
}
return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetBounds(sash);
}
-void* LayoutPartSash::GetControl()
+QWidget* LayoutPartSash::GetControl()
{
return sash;
}
QString LayoutPartSash::GetID() const
{
return "";
}
LayoutPartSash::Pointer LayoutPartSash::GetPostLimit()
{
return postLimit;
}
LayoutPartSash::Pointer LayoutPartSash::GetPreLimit()
{
return preLimit;
}
int LayoutPartSash::GetLeft()
{
return left;
}
int LayoutPartSash::GetRight()
{
return right;
}
bool LayoutPartSash::IsHorizontal()
{
return ((style & Constants::HORIZONTAL) == Constants::HORIZONTAL);
}
bool LayoutPartSash::IsVertical()
{
return ((style & Constants::VERTICAL) == Constants::VERTICAL);
}
void LayoutPartSash::SetPostLimit(LayoutPartSash::Pointer newPostLimit)
{
postLimit = newPostLimit;
}
void LayoutPartSash::SetPreLimit(LayoutPartSash::Pointer newPreLimit)
{
preLimit = newPreLimit;
}
void LayoutPartSash::SetRatio(float newRatio)
{
int total = left + right;
int newLeft = (int) (total * newRatio);
this->SetSizes(newLeft, total - newLeft);
}
void LayoutPartSash::SetSizes(int left, int right)
{
if (left < 0 || right < 0)
{
return;
}
if (left == this->left && right == this->right)
{
return;
}
this->left = left;
this->right = right;
this->FlushCache();
}
void LayoutPartSash::FlushCache()
{
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
if (root != 0)
{
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
if (node != 0)
{
node->FlushCache();
}
}
}
void LayoutPartSash::WidgetSelected(int x, int y, int /*width*/, int /*height*/)
{
if (!enabled)
{
return;
}
LayoutTree::Pointer root = rootContainer->GetLayoutTree();
LayoutTreeNode::Pointer node = root->FindSash(LayoutPartSash::Pointer(this));
QRect nodeBounds = node->GetBounds();
//Recompute ratio
x -= nodeBounds.x();
y -= nodeBounds.y();
if (style == Constants::VERTICAL)
{
this->SetSizes(x, nodeBounds.width() - x - this->GetSashSize());
}
else
{
this->SetSizes(y, nodeBounds.height() - y - this->GetSashSize());
}
node->SetBounds(nodeBounds);
}
void LayoutPartSash::SetEnabled(bool resizable)
{
this->enabled = resizable;
if (sash != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(sash, enabled);
}
}
int LayoutPartSash::GetSashSize() const
{
IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory();
int sashStyle = IPresentationFactory::SASHTYPE_NORMAL | style;
int size = factory->GetSashSize(sashStyle);
return size;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
index ef5d5dadfc..a5af887b8e 100755
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutPartSash.h
@@ -1,184 +1,184 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTPARTSASH_H_
#define BERRYLAYOUTPARTSASH_H_
#include "berryLayoutPart.h"
#include "berryPartSashContainer.h"
#include "guitk/berryGuiTkISelectionListener.h"
#include "presentations/berryIPresentationFactory.h"
#include
namespace berry
{
class LayoutPartSash: public LayoutPart
{
friend class WorkbenchPage;
friend class PartSashContainer;
friend class LayoutTreeNode;
public:
berryObjectMacro(LayoutPartSash);
LayoutPartSash(PartSashContainer* rootContainer, int style);
~LayoutPartSash();
private:
- void* sash;
+ QWidget* sash;
bool enabled;
PartSashContainer* rootContainer;
int style;
LayoutPartSash::Pointer preLimit;
LayoutPartSash::Pointer postLimit;
int left;
int right;
QRect bounds;
IPresentationFactory* presFactory;
/**
* Stores whether or not the sash is visible. (This is expected to have a meaningful
* value even if the underlying control doesn't exist).
*/
bool isVisible;
struct SelectionListener : public GuiTk::ISelectionListener
{
SelectionListener(LayoutPartSash* layoutPartSash);
void WidgetSelected(GuiTk::SelectionEvent::Pointer e);
private: LayoutPartSash* layoutPartSash;
};
GuiTk::ISelectionListener::Pointer selectionListener;
// checkDragLimit contains changes by cagatayk@acm.org
void CheckDragLimit(GuiTk::SelectionEvent::Pointer event);
/**
* Creates the control. As an optimization, creation of the control is deferred if
* the control is invisible.
*/
public:
- void CreateControl(void* parent);
+ void CreateControl(QWidget* parent);
/**
* Creates the underlying SWT control.
*
* @since 3.1
*/
private:
void DoCreateControl();
public:
void SetBounds(const QRect& r);
/**
* Makes the sash visible or invisible. Note: as an optimization, the actual widget is destroyed when the
* sash is invisible.
*/
public:
void SetVisible(bool visible);
public:
bool IsVisible();
/**
* See LayoutPart#dispose
*/
public:
void Dispose();
/**
* Gets the presentation bounds.
*/
public:
QRect GetBounds();
/**
* Returns the part control.
*/
public:
- void* GetControl();
+ QWidget* GetControl();
/**
*
*/
public:
QString GetID() const;
protected:
LayoutPartSash::Pointer GetPostLimit();
LayoutPartSash::Pointer GetPreLimit();
int GetLeft();
int GetRight();
bool IsHorizontal();
bool IsVertical();
void SetPostLimit(LayoutPartSash::Pointer newPostLimit);
void SetPreLimit(LayoutPartSash::Pointer newPreLimit);
void SetRatio(float newRatio);
void SetSizes(int left, int right);
private:
void FlushCache();
private:
void WidgetSelected(int x, int y, int width, int height);
/**
* @param resizable
* @since 3.1
*/
public:
void SetEnabled(bool resizable);
protected:
/* package */int GetSashSize() const;
};
}
#endif /* BERRYLAYOUTPARTSASH_H_ */
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
index fdab418d8c..dcafd29c70 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.cpp
@@ -1,481 +1,481 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutTree.h"
#include "berryLayoutTreeNode.h"
#include "berryLayoutPartSash.h"
#include "berryConstants.h"
#include "berryLog.h"
namespace berry
{
int LayoutTree::minCacheHits = 0;
int LayoutTree::minCacheMisses = 0;
int LayoutTree::maxCacheHits = 0;
int LayoutTree::maxCacheMisses = 0;
LayoutTree::LayoutTree(LayoutPart::Pointer part)
: parent(0),
cachedMinimumWidthHint(Constants::DEFAULT),
cachedMinimumWidth(Constants::DEFAULT),
cachedMinimumHeightHint(Constants::DEFAULT),
cachedMinimumHeight(Constants::DEFAULT),
cachedMaximumWidthHint(Constants::DEFAULT),
cachedMaximumWidth(Constants::DEFAULT),
cachedMaximumHeightHint(Constants::DEFAULT),
cachedMaximumHeight(Constants::DEFAULT),
forceLayout(true),
sizeFlagsDirty(true),
widthSizeFlags(0),
heightSizeFlags(0)
{
this->part = part;
}
LayoutPart::Pointer LayoutTree::ComputeRelation(
QList& /*relations*/)
{
return part;
}
LayoutPart::Pointer LayoutTree::FindPart(const QPoint& /*toFind*/)
{
return part;
}
void LayoutTree::DisposeSashes()
{
}
LayoutTree::Pointer LayoutTree::Find(LayoutPart::Pointer child)
{
if (part != child)
{
return LayoutTree::Pointer(0);
}
return LayoutTree::Pointer(this);
}
void LayoutTree::FindSashes(PartPane::Sashes sashes)
{
if (this->GetParent() == 0)
{
return;
}
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
LayoutPart::Pointer LayoutTree::FindBottomRight()
{
return part;
}
LayoutTreeNode::Pointer LayoutTree::FindSash(LayoutPartSash::Pointer /*sash*/)
{
return LayoutTreeNode::Pointer(0);
}
QRect LayoutTree::GetBounds()
{
return currentBounds;
}
int LayoutTree::Subtract(int a, int b)
{
poco_assert(b >= 0 && b < INF);
return Add(a, -b);
}
int LayoutTree::Add(int a, int b)
{
if (a == INF || b == INF)
{
return INF;
}
return a + b;
}
void LayoutTree::AssertValidSize(int toCheck)
{
poco_assert(toCheck >= 0 && (toCheck == INF || toCheck < INF / 2));
}
int LayoutTree::ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availableParallel);
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(preferredParallel);
if (!this->IsVisible())
{
return 0;
}
if (availableParallel == 0)
{
return 0;
}
if (preferredParallel == 0)
{
return std::min(availableParallel, this->ComputeMinimumSize(width,
availablePerpendicular));
}
else if (preferredParallel == INF && availableParallel == INF)
{
return this->ComputeMaximumSize(width, availablePerpendicular);
}
// Optimization: if this subtree doesn't have any size preferences beyond its minimum and maximum
// size, simply return the preferred size
if (!this->HasSizeFlag(width, Constants::FILL))
{
return preferredParallel;
}
int result = this->DoComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
return result;
}
int LayoutTree::DoGetSizeFlags(bool width)
{
return part->GetSizeFlags(width);
}
int LayoutTree::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
int result = std::min(availableParallel, part->ComputePreferredSize(width,
availableParallel, availablePerpendicular, preferredParallel));
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMinimumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no minimum size, then always return 0 as its
// minimum size.
if (!this->HasSizeFlag(width, Constants::MIN))
{
return 0;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time for non-wrapping controls.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMinimumWidthHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumWidth;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumWidth = result;
cachedMinimumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement (we can only return a cached
// value if we computed it for the same width)
if (cachedMinimumHeightHint == availablePerpendicular)
{
minCacheHits++;
return cachedMinimumHeight;
}
// Recompute the minimum width and store it in the cache
minCacheMisses++;
int result = this->DoComputeMinimumSize(width, availablePerpendicular);
cachedMinimumHeight = result;
cachedMinimumHeightHint = availablePerpendicular;
return result;
}
}
void LayoutTree::PrintCacheStatistics()
{
BERRY_INFO << "minimize cache " << minCacheHits << " / " << (minCacheHits
+ minCacheMisses) << " hits " <<
(minCacheHits * 100 / (minCacheHits + minCacheMisses)) << "%\n";
BERRY_INFO << "maximize cache " << maxCacheHits << " / " << (maxCacheHits
+ maxCacheMisses) << " hits" <<
(maxCacheHits * 100 / (maxCacheHits + maxCacheMisses)) << "%\n";
}
int LayoutTree::DoComputeMinimumSize(bool width, int availablePerpendicular)
{
int result = this->DoComputePreferredSize(width, INF, availablePerpendicular,
0);
this->AssertValidSize(result);
return result;
}
int LayoutTree::ComputeMaximumSize(bool width, int availablePerpendicular)
{
this->AssertValidSize(availablePerpendicular);
// Optimization: if this subtree has no maximum size, then always return INF as its
// maximum size.
if (!this->HasSizeFlag(width, Constants::MAX))
{
return INF;
}
// If this subtree doesn't contain any wrapping controls (ie: they don't care
// about their perpendicular size) then force the perpendicular
// size to be INF. This ensures that we will get a cache hit
// every time.
if (!this->HasSizeFlag(width, Constants::WRAP))
{
availablePerpendicular = INF;
}
if (width)
{
// Check if we have a cached width measurement (we can only return a cached
// value if we computed it for the same height)
if (cachedMaximumWidthHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumWidth;
}
maxCacheMisses++;
// Recompute the maximum width and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumWidth = result;
cachedMaximumWidthHint = availablePerpendicular;
return result;
}
else
{
// Check if we have a cached height measurement
if (cachedMaximumHeightHint == availablePerpendicular)
{
maxCacheHits++;
return cachedMaximumHeight;
}
maxCacheMisses++;
// Recompute the maximum height and store it in the cache
int result = this->DoComputeMaximumSize(width, availablePerpendicular);
cachedMaximumHeight = result;
cachedMaximumHeightHint = availablePerpendicular;
return result;
}
}
int LayoutTree::DoComputeMaximumSize(bool width, int availablePerpendicular)
{
return this->DoComputePreferredSize(width, INF, availablePerpendicular,
INF);
}
void LayoutTree::FlushNode()
{
// Clear cached sizes
cachedMinimumWidthHint = Constants::DEFAULT;
cachedMinimumWidth = Constants::DEFAULT;
cachedMinimumHeightHint = Constants::DEFAULT;
cachedMinimumHeight = Constants::DEFAULT;
cachedMaximumWidthHint = Constants::DEFAULT;
cachedMaximumWidth = Constants::DEFAULT;
cachedMaximumHeightHint = Constants::DEFAULT;
cachedMaximumHeight = Constants::DEFAULT;
// Flags may have changed. Ensure that they are recomputed the next time around
sizeFlagsDirty = true;
// The next setBounds call should trigger a layout even if set to the same bounds since
// one of the children has changed.
forceLayout = true;
}
void LayoutTree::FlushChildren()
{
this->FlushNode();
}
void LayoutTree::FlushCache()
{
this->FlushNode();
if (parent != 0)
{
parent->FlushCache();
}
}
int LayoutTree::GetSizeFlags(bool width)
{
if (sizeFlagsDirty)
{
widthSizeFlags = this->DoGetSizeFlags(true);
heightSizeFlags = this->DoGetSizeFlags(false);
sizeFlagsDirty = false;
}
return width ? widthSizeFlags : heightSizeFlags;
}
LayoutTreeNode* LayoutTree::GetParent() const
{
return parent;
}
LayoutTree::Pointer LayoutTree::Insert(LayoutPart::Pointer child, bool left,
LayoutPartSash::Pointer sash, LayoutPart::Pointer relative)
{
LayoutTree::Pointer relativeChild = this->Find(relative);
LayoutTreeNode::Pointer node(new LayoutTreeNode(sash));
if (relativeChild == 0)
{
//Did not find the relative part. Insert beside the root.
node->SetChild(left, child);
node->SetChild(!left, LayoutTree::Pointer(this));
return node;
}
else
{
LayoutTreeNode* oldParent = relativeChild->GetParent();
node->SetChild(left, child);
node->SetChild(!left, relativeChild);
if (oldParent == 0)
{
//It was the root. Return a new root.
return node;
}
oldParent->ReplaceChild(relativeChild, node);
return LayoutTree::Pointer(this);
}
}
bool LayoutTree::IsCompressible()
{
//Added for bug 19524
return part->IsCompressible();
}
bool LayoutTree::IsVisible()
{
return !part->IsPlaceHolder();
}
void LayoutTree::RecomputeRatio()
{
}
LayoutTree::Pointer LayoutTree::Remove(LayoutPart::Pointer child)
{
LayoutTree::Pointer tree = this->Find(child);
if (tree == 0)
{
return LayoutTree::Pointer(this);
}
LayoutTreeNode::Pointer oldParent(tree->GetParent());
if (oldParent == 0)
{
//It was the root and the only child of this tree
return LayoutTree::Pointer(0);
}
if (oldParent->GetParent() == 0)
{
return oldParent->Remove(tree);
}
oldParent->Remove(tree);
return LayoutTree::Pointer(this);
}
void LayoutTree::SetBounds(const QRect& bounds)
{
if (!(bounds == currentBounds) || forceLayout)
{
currentBounds = bounds;
this->DoSetBounds(currentBounds);
forceLayout = false;
}
}
void LayoutTree::DoSetBounds(const QRect& bounds)
{
part->SetBounds(bounds);
}
void LayoutTree::SetParent(LayoutTreeNode* parent)
{
this->parent = parent;
}
void LayoutTree::SetPart(LayoutPart::Pointer part)
{
this->part = part;
this->FlushCache();
}
QString LayoutTree::ToString() const
{
return "(" + part->ToString() + ")";
}
-void LayoutTree::CreateControl(void* /*parent*/)
+void LayoutTree::CreateControl(QWidget* /*parent*/)
{
}
void LayoutTree::DescribeLayout(QString& buf) const
{
part->DescribeLayout(buf);
}
bool LayoutTree::HasSizeFlag(bool width, int flag)
{
return (this->GetSizeFlags(width) & flag) != 0;
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
index 9cb62bd853..39e7a12475 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTree.h
@@ -1,370 +1,370 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTTREE_H_
#define BERRYLAYOUTTREE_H_
#include "berryISizeProvider.h"
#include "berryPartSashContainer.h"
#include
namespace berry
{
class LayoutTreeNode;
class LayoutPartSash;
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree where the node is allways a sash
* and it allways has two chidren. If a children is removed
* the sash, ie the node, is removed as well and its other children
* placed on its parent.
*/
class LayoutTree : public Object, public ISizeProvider
{ //implements ISizeProvider {
public:
berryObjectMacro(LayoutTree)
/* The parent of this tree or null if it is the root */
LayoutTreeNode* parent;
/* Any LayoutPart if this is a leaf or a LayoutSashPart if it is a node */
LayoutPart::Pointer part;
private:
// Cached information
int cachedMinimumWidthHint;
int cachedMinimumWidth;
int cachedMinimumHeightHint;
int cachedMinimumHeight;
int cachedMaximumWidthHint;
int cachedMaximumWidth;
int cachedMaximumHeightHint;
int cachedMaximumHeight;
bool forceLayout;
QRect currentBounds;
// Cached size flags
bool sizeFlagsDirty;
int widthSizeFlags;
int heightSizeFlags;
public:
// Cache statistics. For use in benchmarks and test suites only!
static int minCacheHits;
static int minCacheMisses;
static int maxCacheHits;
static int maxCacheMisses;
/**
* Initialize this tree with its part.
*/
LayoutTree(LayoutPart::Pointer part);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
virtual LayoutPart::Pointer ComputeRelation(
QList& relations);
/**
* Locates the part that intersects the given point
*
* @param toFind
* @return
*/
virtual LayoutPart::Pointer FindPart(const QPoint& toFind);
/**
* Dispose all Sashs in this tree
*/
virtual void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
virtual SmartPointer Find(LayoutPart::Pointer child);
/**
* Find the Left,Right,Top and Bottom
* sashes around this tree and set them
* in sashes
*/
virtual void FindSashes(PartPane::Sashes sashes);
/**
* Find the part that is in the bottom right position.
*/
virtual LayoutPart::Pointer FindBottomRight();
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
virtual SmartPointer FindSash(SmartPointer sash);
/**
* Return the bounds of this tree which is the rectangle that
* contains all Controls in this tree.
*/
QRect GetBounds();
/**
* Subtracts two integers. If a is INF, this is treated as
* positive infinity.
*
* @param a a positive integer or INF indicating positive infinity
* @param b a positive integer (may not be INF)
* @return a - b, or INF if a == INF
* @since 3.1
*/
static int Subtract(int a, int b);
/**
* Adds two positive integers. Treates INF as positive infinity.
*
* @param a a positive integer
* @param b a positive integer
* @return a + b, or INF if a or b are positive infinity
* @since 3.1
*/
static int Add(int a, int b);
/**
* Asserts that toCheck is a positive integer less than INF / 2 or equal
* to INF. Many of the methods of this class use positive integers as sizes,
* with INF indicating positive infinity. This picks up accidental addition or
* subtraction from infinity.
*
* @param toCheck integer to validate
* @since 3.1
*/
static void AssertValidSize(int toCheck);
/**
* Computes the preferred size for this object. The interpretation of the result depends on the flags returned
* by getSizeFlags(). If the caller is looking for a maximum or minimum size, this delegates to computeMinimumSize
* or computeMaximumSize in order to benefit from caching optimizations. Otherwise, it delegates to
* doComputePreferredSize. Subclasses should overload one of doComputeMinimumSize, doComputeMaximumSize, or
* doComputePreferredSize to specialize the return value.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
protected:
/**
* Returns the size flags for this tree.
*
* @see org.blueberry.ui.presentations.StackPresentation#getSizeFlags(boolean)
*
* @param b indicates whether the caller wants the flags for computing widths (=true) or heights (=false)
* @return a bitwise combiniation of flags with the same meaning as StackPresentation.getSizeFlags(boolean)
*/
virtual int DoGetSizeFlags(bool width);
/**
* Subclasses should overload this method instead of computePreferredSize(boolean, int, int, int)
*
* @see org.blueberry.ui.presentations.StackPresentation#computePreferredSize(boolean, int, int, int)
*
* @since 3.1
*/
virtual int DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel);
public:
/**
* Returns the minimum size for this subtree. Equivalent to calling
* computePreferredSize(width, INF, availablePerpendicular, 0).
* Returns a cached value if possible or defers to doComputeMinimumSize otherwise.
* Subclasses should overload doComputeMinimumSize if they want to specialize the
* return value.
*
* @param width true iff computing the minimum width, false iff computing the minimum height
* @param availablePerpendicular available space (pixels) perpendicular to the dimension
* being computed. This is a height when computing a width, or a width when computing a height.
*
* @see LayoutPart#computePreferredSize(boolean, int, int, int)
*/
int ComputeMinimumSize(bool width, int availablePerpendicular);
/**
* For use in benchmarks and test suites only. Displays cache utilization statistics for all
* LayoutTree instances.
*
* @since 3.1
*/
static void PrintCacheStatistics();
virtual int DoComputeMinimumSize(bool width, int availablePerpendicular);
int ComputeMaximumSize(bool width, int availablePerpendicular);
protected:
virtual int DoComputeMaximumSize(bool width, int availablePerpendicular);
public:
/**
* Called to flush any cached information in this tree and its parents.
*/
virtual void FlushNode();
/**
* Flushes all cached information about this node and all of its children.
* This should be called if something may have caused all children to become
* out of synch with their cached information (for example, if a lot of changes
* may have happened without calling flushCache after each change)
*
* @since 3.1
*/
virtual void FlushChildren();
/**
* Flushes all cached information about this node and all of its ancestors.
* This should be called when a single child changes.
*
* @since 3.1
*/
void FlushCache();
int GetSizeFlags(bool width);
/**
* Returns the parent of this tree or null if it is the root.
*/
virtual LayoutTreeNode* GetParent() const;
/**
* Inserts a new child on the tree. The child will be placed beside
* the relative
child. Returns the new root of the tree.
*/
virtual SmartPointer Insert(LayoutPart::Pointer child, bool left,
SmartPointer sash, SmartPointer relative);
/**
* Returns true if this tree can be compressed and expanded.
* @return true if springy
*/
virtual bool IsCompressible();
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
virtual bool IsVisible();
/**
* Recompute the ratios in this tree.
*/
virtual void RecomputeRatio();
/**
* Find a child in the tree and remove it and its parent.
* The other child of its parent is placed on the parent's parent.
* Returns the new root of the tree.
*/
virtual SmartPointer Remove(LayoutPart::Pointer child);
/**
* Sets the bounds of this node. If the bounds have changed or any children have
* changed then the children will be recursively layed out. This implementation
* filters out redundant calls and delegates to doSetBounds to layout the children.
* Subclasses should overload doSetBounds to lay out their children.
*
* @param bounds new bounds of the tree
*/
void SetBounds(const QRect& bounds);
protected:
/**
* Resize the parts on this tree to fit in bounds
.
*/
virtual void DoSetBounds(const QRect& bounds);
public:
/**
* Set the parent of this tree.
*/
virtual void SetParent(LayoutTreeNode* parent);
/**
* Set the part of this leaf
*/
virtual void SetPart(LayoutPart::Pointer part);
/**
* Returns a string representation of this object.
*/
virtual QString ToString() const;
/**
* Creates SWT controls owned by the LayoutTree (ie: the sashes). Does not affect the
* LayoutParts that are being arranged by the LayoutTree.
*
* @param parent
* @since 3.1
*/
- virtual void CreateControl(void* parent);
+ virtual void CreateControl(QWidget* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* This is only intended for use by test suites.
*
*
* @param buf
*/
virtual void DescribeLayout(QString& buf) const;
/**
* This is a shorthand method that checks if the tree contains the
* given size flag. For example, hasSizeFlag(false, SWT.MIN) returns
* true iff the receiver enforces a minimum height, or
* hasSizeFlag(true, SWT.WRAP) returns true iff the receiver needs to
* know its height when computing its preferred width.
*
* @param vertical
* @return
* @since 3.1
*/
bool HasSizeFlag(bool width, int flag);
};
}
#endif /*BERRYLAYOUTTREE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
index 2193b84808..accd9fdb60 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.cpp
@@ -1,723 +1,723 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryLayoutTreeNode.h"
#include "berryConstants.h"
#include "berryIPageLayout.h"
#include
namespace berry
{
LayoutTreeNode::ChildSizes::ChildSizes (int l, int r, bool resize)
{
left = l;
right = r;
resizable = resize;
}
LayoutTreeNode::LayoutTreeNode(LayoutPartSash::Pointer sash)
: LayoutTree(sash)
{
children[0] = 0;
children[1] = 0;
}
LayoutTreeNode::~LayoutTreeNode()
{
}
void LayoutTreeNode::FlushChildren()
{
LayoutTree::FlushChildren();
children[0]->FlushChildren();
children[1]->FlushChildren();
}
LayoutPart::Pointer LayoutTreeNode::FindPart(const QPoint& toFind)
{
if (!children[0]->IsVisible())
{
if (!children[1]->IsVisible())
{
return LayoutPart::Pointer(0);
}
return children[1]->FindPart(toFind);
}
else
{
if (!children[1]->IsVisible())
{
return children[0]->FindPart(toFind);
}
}
LayoutPartSash::Pointer sash = this->GetSash();
QRect bounds = sash->GetBounds();
if (sash->IsVertical())
{
if (toFind.x() < bounds.x() + (bounds.width() / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
else
{
if (toFind.y() < bounds.y() + (bounds.height() / 2))
{
return children[0]->FindPart(toFind);
}
return children[1]->FindPart(toFind);
}
}
LayoutPart::Pointer LayoutTreeNode::ComputeRelation(
QList& relations)
{
PartSashContainer::RelationshipInfo r =
PartSashContainer::RelationshipInfo();
r.relative = children[0]->ComputeRelation(relations);
r.part = children[1]->ComputeRelation(relations);
r.left = this->GetSash()->GetLeft();
r.right = this->GetSash()->GetRight();
r.relationship = this->GetSash()->IsVertical() ? IPageLayout::RIGHT : IPageLayout::BOTTOM;
relations.push_front(r);
return r.relative;
}
void LayoutTreeNode::DisposeSashes()
{
children[0]->DisposeSashes();
children[1]->DisposeSashes();
this->GetSash()->Dispose();
}
LayoutTree::Pointer LayoutTreeNode::Find(LayoutPart::Pointer child)
{
LayoutTree::Pointer node = children[0]->Find(child);
if (node != 0)
{
return node;
}
node = children[1]->Find(child);
return node;
}
LayoutPart::Pointer LayoutTreeNode::FindBottomRight()
{
if (children[1]->IsVisible())
{
return children[1]->FindBottomRight();
}
return children[0]->FindBottomRight();
}
LayoutTreeNode* LayoutTreeNode::FindCommonParent(LayoutPart::Pointer child1,
LayoutPart::Pointer child2, bool foundChild1,
bool foundChild2)
{
if (!foundChild1)
{
foundChild1 = this->Find(child1) != 0;
}
if (!foundChild2)
{
foundChild2 = this->Find(child2) != 0;
}
if (foundChild1 && foundChild2)
{
return this;
}
if (parent == 0)
{
return 0;
}
return parent
->FindCommonParent(child1, child2, foundChild1, foundChild2);
}
LayoutTreeNode::Pointer LayoutTreeNode::FindSash(LayoutPartSash::Pointer sash)
{
if (this->GetSash() == sash)
{
return LayoutTreeNode::Pointer(this);
}
LayoutTreeNode::Pointer node = children[0]->FindSash(sash);
if (node != 0)
{
return node;
}
node = children[1]->FindSash(sash);
if (node != 0)
{
return node;
}
return LayoutTreeNode::Pointer(0);
}
void LayoutTreeNode::FindSashes(LayoutTree::Pointer child, PartPane::Sashes sashes)
{
- void* sash = this->GetSash()->GetControl();
+ QWidget* sash = this->GetSash()->GetControl();
bool leftOrTop = children[0] == child;
if (sash != 0)
{
LayoutPartSash::Pointer partSash = this->GetSash();
//If the child is in the left, the sash
//is in the rigth and so on.
if (leftOrTop)
{
if (partSash->IsVertical())
{
if (sashes.right == 0)
{
sashes.right = sash;
}
}
else
{
if (sashes.bottom == 0)
{
sashes.bottom = sash;
}
}
}
else
{
if (partSash->IsVertical())
{
if (sashes.left == 0)
{
sashes.left = sash;
}
}
else
{
if (sashes.top == 0)
{
sashes.top = sash;
}
}
}
}
if (this->GetParent() != 0)
{
this->GetParent()->FindSashes(LayoutTree::Pointer(this), sashes);
}
}
LayoutPartSash::Pointer LayoutTreeNode::GetSash() const
{
return part.Cast();
}
int LayoutTreeNode::GetSashSize() const
{
return this->GetSash()->GetSashSize();
}
bool LayoutTreeNode::IsVisible()
{
return children[0]->IsVisible() || children[1]->IsVisible();
}
LayoutTree::Pointer LayoutTreeNode::Remove(LayoutTree::Pointer child)
{
this->GetSash()->Dispose();
if (parent == 0)
{
//This is the root. Return the other child to be the new root.
if (children[0] == child)
{
children[1]->SetParent(0);
return children[1];
}
children[0]->SetParent(0);
return children[0];
}
LayoutTreeNode::Pointer oldParent(parent);
if (children[0] == child)
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[1]);
}
else
{
oldParent->ReplaceChild(LayoutTree::Pointer(this), children[0]);
}
return oldParent;
}
void LayoutTreeNode::ReplaceChild(LayoutTree::Pointer oldChild, LayoutTree::Pointer newChild)
{
if (children[0] == oldChild)
{
children[0] = newChild;
}
else if (children[1] == oldChild)
{
children[1] = newChild;
}
newChild->SetParent(this);
if (!children[0]->IsVisible() || !children[0]->IsVisible())
{
this->GetSash()->Dispose();
}
this->FlushCache();
}
bool LayoutTreeNode::SameDirection(bool isVertical, LayoutTreeNode::Pointer subTree)
{
bool treeVertical = this->GetSash()->IsVertical();
if (treeVertical != isVertical)
{
return false;
}
while (subTree != 0)
{
if (this == subTree.GetPointer())
{
return true;
}
if (subTree->children[0]->IsVisible() && subTree->children[1]->IsVisible())
{
if (subTree->GetSash()->IsVertical() != isVertical)
{
return false;
}
}
subTree = subTree->GetParent();
}
return true;
}
int LayoutTreeNode::DoComputePreferredSize(bool width, int availableParallel,
int availablePerpendicular, int preferredParallel)
{
this->AssertValidSize(availablePerpendicular);
this->AssertValidSize(availableParallel);
this->AssertValidSize(preferredParallel);
// If one child is invisible, defer to the other child
if (!children[0]->IsVisible())
{
return children[1]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (!children[1]->IsVisible())
{
return children[0]->ComputePreferredSize(width, availableParallel,
availablePerpendicular, preferredParallel);
}
if (availableParallel == 0)
{
return 0;
}
// If computing the dimension perpendicular to our sash
if (width == this->GetSash()->IsVertical())
{
// Compute the child sizes
ChildSizes sizes = this->ComputeChildSizes(availableParallel,
availablePerpendicular,
GetSash()->GetLeft(), GetSash()->GetRight(), preferredParallel);
// Return the sum of the child sizes plus the sash size
return this->Add(sizes.left, this->Add(sizes.right, this->GetSashSize()));
}
else
{
// Computing the dimension parallel to the sash. We will compute and return the preferred size
// of whichever child is closest to the ideal size.
// First compute the dimension of the child sizes perpendicular to the sash
ChildSizes sizes = this->ComputeChildSizes(availablePerpendicular, availableParallel,
GetSash()->GetLeft(), GetSash()->GetRight(), availablePerpendicular);
// Use this information to compute the dimension of the child sizes parallel to the sash.
// Return the preferred size of whichever child is largest
int leftSize = children[0]->ComputePreferredSize(width, availableParallel,
sizes.left, preferredParallel);
// Compute the preferred size of the right child
int rightSize = children[1]->ComputePreferredSize(width, availableParallel,
sizes.right, preferredParallel);
// Return leftSize or rightSize: whichever one is largest
int result = rightSize;
if (leftSize > rightSize)
{
result = leftSize;
}
this->AssertValidSize(result);
return result;
}
}
LayoutTreeNode::ChildSizes LayoutTreeNode::ComputeChildSizes(int width, int height, int left,
int right, int preferredWidth)
{
poco_assert(children[0]->IsVisible());
poco_assert(children[1]->IsVisible());
this->AssertValidSize(width);
this->AssertValidSize(height);
this->AssertValidSize(preferredWidth);
poco_assert(left >= 0);
poco_assert(right >= 0);
poco_assert(preferredWidth >= 0);
poco_assert(preferredWidth <= width);
bool vertical = this->GetSash()->IsVertical();
if (width <= this->GetSashSize())
{
return ChildSizes(0,0, false);
}
if (width == INF)
{
if (preferredWidth == INF)
{
return ChildSizes(children[0]->ComputeMaximumSize(vertical, height),
children[1]->ComputeMaximumSize(vertical, height), false);
}
if (preferredWidth == 0)
{
return ChildSizes(children[0]->ComputeMinimumSize(vertical, height),
children[1]->ComputeMinimumSize(vertical, height), false);
}
}
int total = left + right;
// Use all-or-none weighting
double wLeft = left, wRight = right;
switch (this->GetCompressionBias())
{
case -1:
wLeft = 0.0;
break;
case 1:
wRight = 0.0;
break;
default:
break;
}
double wTotal = wLeft + wRight;
// Subtract the SASH_WIDTH from preferredWidth and width. From here on, we'll deal with the
// width available to the controls and neglect the space used by the sash.
preferredWidth = std::max(0, this->Subtract(preferredWidth, this->GetSashSize()));
width = std::max(0, this->Subtract(width, this->GetSashSize()));
int redistribute = this->Subtract(preferredWidth, total);
// Compute the minimum and maximum sizes for each child
int leftMinimum = children[0]->ComputeMinimumSize(vertical, height);
int rightMinimum = children[1]->ComputeMinimumSize(vertical, height);
int leftMaximum = children[0]->ComputeMaximumSize(vertical, height);
int rightMaximum = children[1]->ComputeMaximumSize(vertical, height);
int idealLeft = 0;
int idealRight = 0;
if (PartSashContainer::leftToRight)
{
// Keep track of the available space for each child, given the minimum size of the other child
int leftAvailable = std::min(leftMaximum, std::max(0, this->Subtract(width,
rightMinimum)));
int rightAvailable = std::min(rightMaximum, std::max(0, this->Subtract(width,
leftMinimum)));
// Figure out the ideal size of the left child
idealLeft = std::max(leftMinimum, std::min(preferredWidth, left
+ (int)(redistribute * wLeft / wTotal)));
// If the right child can't use all its available space, let the left child fill it in
idealLeft = std::max(idealLeft, preferredWidth - rightAvailable);
// Ensure the left child doesn't get larger than its available space
idealLeft = std::min(idealLeft, leftAvailable);
// Check if the left child would prefer to be a different size
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable, height,
idealLeft);
// Ensure that the left child is larger than its minimum size
idealLeft = std::max(idealLeft, leftMinimum);
idealLeft = std::min(idealLeft, leftAvailable);
// Compute the right child width
idealRight = std::max(rightMinimum, preferredWidth - idealLeft);
rightAvailable = std::max(0, std::min(rightAvailable, this->Subtract(width,
idealLeft)));
idealRight = std::min(idealRight, rightAvailable);
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable,
height, idealRight);
idealRight = std::max(idealRight, rightMinimum);
}
else
{
// Keep track of the available space for each child, given the minimum size of the other child
int rightAvailable = std::min(rightMaximum, std::max(0, this->Subtract(width,
leftMinimum)));
int leftAvailable = std::min(leftMaximum, std::max(0, this->Subtract(width,
rightMinimum)));
// Figure out the ideal size of the right child
idealRight = std::max(rightMinimum, std::min(preferredWidth, right
+ (int)(redistribute * wRight / wTotal)));
// If the left child can't use all its available space, let the right child fill it in
idealRight = std::max(idealRight, preferredWidth - leftAvailable);
// Ensure the right child doesn't get larger than its available space
idealRight = std::min(idealRight, rightAvailable);
// Check if the right child would prefer to be a different size
idealRight = children[1]->ComputePreferredSize(vertical, rightAvailable, height,
idealRight);
// Ensure that the right child is larger than its minimum size
idealRight = std::max(idealRight, rightMinimum);
idealRight = std::min(idealRight, rightAvailable);
// Compute the left child width
idealLeft = std::max(leftMinimum, preferredWidth - idealRight);
leftAvailable = std::max(0, std::min(leftAvailable, this->Subtract(width,
idealRight)));
idealLeft = std::min(idealLeft, leftAvailable);
idealLeft = children[0]->ComputePreferredSize(vertical, leftAvailable,
height, idealLeft);
idealLeft = std::max(idealLeft, leftMinimum);
}
return ChildSizes(idealLeft, idealRight, leftMaximum> leftMinimum
&& rightMaximum> rightMinimum
&& leftMinimum + rightMinimum < width);
}
int LayoutTreeNode::DoGetSizeFlags(bool width)
{
if (!children[0]->IsVisible())
{
return children[1]->GetSizeFlags(width);
}
if (!children[1]->IsVisible())
{
return children[0]->GetSizeFlags(width);
}
int leftFlags = children[0]->GetSizeFlags(width);
int rightFlags = children[1]->GetSizeFlags(width);
return ((leftFlags | rightFlags) & ~Constants::MAX) | (leftFlags & rightFlags
& Constants::MAX);
}
void LayoutTreeNode::DoSetBounds(const QRect& b)
{
if (!children[0]->IsVisible())
{
children[1]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
if (!children[1]->IsVisible())
{
children[0]->SetBounds(b);
this->GetSash()->SetVisible(false);
return;
}
QRect bounds = b;
bool vertical = this->GetSash()->IsVertical();
// If this is a horizontal sash, flip coordinate systems so
// that we can eliminate special cases
if (!vertical)
{
bounds = FlipRect(bounds);
}
ChildSizes childSizes = this->ComputeChildSizes(bounds.width(), bounds.height(),
this->GetSash()->GetLeft(), this->GetSash()->GetRight(), bounds.width());
this->GetSash()->SetVisible(true);
this->GetSash()->SetEnabled(childSizes.resizable);
QRect leftBounds = QRect(bounds.x(), bounds.y(), childSizes.left, bounds.height());
QRect sashBounds = QRect(leftBounds.x() + leftBounds.width(), bounds.y(), this->GetSashSize(), bounds.height());
QRect rightBounds = QRect(sashBounds.x() + sashBounds.width(), bounds.y(),
childSizes.right, bounds.height());
if (!vertical)
{
leftBounds = FlipRect(leftBounds);
sashBounds = FlipRect(sashBounds);
rightBounds = FlipRect(rightBounds);
}
this->GetSash()->SetBounds(sashBounds);
children[0]->SetBounds(leftBounds);
children[1]->SetBounds(rightBounds);
}
-void LayoutTreeNode::CreateControl(void* parent)
+void LayoutTreeNode::CreateControl(QWidget* parent)
{
children[0]->CreateControl(parent);
children[1]->CreateControl(parent);
this->GetSash()->CreateControl(parent);
LayoutTree::CreateControl(parent);
}
bool LayoutTreeNode::IsCompressible()
{
return children[0]->IsCompressible() || children[1]->IsCompressible();
}
int LayoutTreeNode::GetCompressionBias()
{
bool left = children[0]->IsCompressible();
bool right = children[1]->IsCompressible();
if (left == right)
{
return 0;
}
if (right)
{
return -1;
}
return 1;
}
bool LayoutTreeNode::IsLeftChild(LayoutTree::ConstPointer toTest)
{
return children[0] == toTest;
}
LayoutTree::Pointer LayoutTreeNode::GetChild(bool left)
{
int index = left ? 0 : 1;
return (children[index]);
}
void LayoutTreeNode::SetChild(bool left, LayoutPart::Pointer part)
{
LayoutTree::Pointer child(new LayoutTree(part));
this->SetChild(left, child);
this->FlushCache();
}
void LayoutTreeNode::SetChild(bool left, LayoutTree::Pointer child)
{
int index = left ? 0 : 1;
children[index] = child;
child->SetParent(this);
this->FlushCache();
}
QString LayoutTreeNode::ToString() const
{
QString str;
QTextStream s(&str);
s << "\n";
if (part->GetControl() != 0)
{
s << "<@" << part->GetControl() << ">\n";
}
QString str2;
QTextStream result(&str2);
result << "[";
if (children[0]->GetParent() != this)
{
result << str2 << "{" << children[0] << "}" << str;
}
else
{
result << str2 << children[0] << str;
}
if (children[1]->GetParent() != this)
{
result << str2 << "{" << children[1] << "}]";
}
else
{
result << str2 << children[1] << "]";
}
return str2;
}
-//void LayoutTreeNode::UpdateSashes(void* parent) {
+//void LayoutTreeNode::UpdateSashes(QWidget* parent) {
// if (parent == 0)
// return;
// children[0]->UpdateSashes(parent);
// children[1]->UpdateSashes(parent);
// if (children[0]->IsVisible() && children[1]->IsVisible())
// this->GetSash()->CreateControl(parent);
// else
// this->GetSash()->Dispose();
// }
void LayoutTreeNode::DescribeLayout(QString& buf) const
{
if (!(children[0]->IsVisible()))
{
if (!children[1]->IsVisible())
{
return;
}
children[1]->DescribeLayout(buf);
return;
}
if (!children[1]->IsVisible())
{
children[0]->DescribeLayout(buf);
return;
}
buf.append("("); //$NON-NLS-1$
children[0]->DescribeLayout(buf);
buf.append(this->GetSash()->IsVertical() ? "|" : "-");
children[1]->DescribeLayout(buf);
buf.append(")");
}
QRect LayoutTreeNode::FlipRect(const QRect& rect)
{
return QRect(rect.y(), rect.x(), rect.height(), rect.width());
}
}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
index 65baa5a47b..0fe032466c 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryLayoutTreeNode.h
@@ -1,229 +1,229 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BERRYLAYOUTTREENODE_H_
#define BERRYLAYOUTTREENODE_H_
#include "berryLayoutTree.h"
#include "berryLayoutPartSash.h"
namespace berry {
/**
* \ingroup org_blueberry_ui_internal
*
* Implementation of a tree node. The node represents a
* sash and it allways has two children.
*/
class LayoutTreeNode : public LayoutTree {
public:
berryObjectMacro(LayoutTreeNode)
struct ChildSizes {
int left;
int right;
bool resizable;
ChildSizes (int l, int r, bool resize);
};
/* The node children witch may be another node or a leaf */
private: LayoutTree::Pointer children[2];
/**
* Initialize this tree with its sash.
*/
public: LayoutTreeNode(LayoutPartSash::Pointer sash);
public: ~LayoutTreeNode();
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#flushChildren()
*/
public: void FlushChildren();
/**
* Traverses the tree to find the part that intersects the given point
*
* @param toFind
* @return the part that intersects the given point
*/
public: LayoutPart::Pointer FindPart(const QPoint& toFind);
/**
* Add the relation ship between the children in the list
* and returns the left children.
*/
public: LayoutPart::Pointer ComputeRelation(QList& relations);
/**
* Dispose all Sashs in this tree
*/
public: void DisposeSashes();
/**
* Find a LayoutPart in the tree and return its sub-tree. Returns
* null if the child is not found.
*/
public: SmartPointer Find(LayoutPart::Pointer child);
/**
* Find the part that is in the bottom right position.
*/
public: LayoutPart::Pointer FindBottomRight();
/**
* Go up in the tree finding a parent that is common of both children.
* Return the subtree.
*/
LayoutTreeNode* FindCommonParent(LayoutPart::Pointer child1, LayoutPart::Pointer child2,
bool foundChild1 = false, bool foundChild2 = false);
/**
* Find a sash in the tree and return its sub-tree. Returns
* null if the sash is not found.
*/
public: SmartPointer FindSash(LayoutPartSash::Pointer sash);
using LayoutTree::FindSashes;
/**
* Sets the elements in the array of sashes with the
* Left,Rigth,Top and Botton sashes. The elements
* may be null depending whether there is a shash
* beside the part
*/
void FindSashes(SmartPointer child, PartPane::Sashes sashes);
/**
* Returns the sash of this node.
*/
public: LayoutPartSash::Pointer GetSash() const;
private: int GetSashSize() const;
/**
* Returns true if this tree has visible parts otherwise returns false.
*/
public: bool IsVisible();
using LayoutTree::Remove;
/**
* Remove the child and this node from the tree
*/
SmartPointer Remove(SmartPointer child);
/**
* Replace a child with a new child and sets the new child's parent.
*/
void ReplaceChild(SmartPointer oldChild, SmartPointer newChild);
/**
* Go up from the subtree and return true if all the sash are
* in the direction specified by isVertical
*/
public: bool SameDirection(bool isVertical, SmartPointer subTree);
public: int DoComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredParallel);
/**
* Computes the pixel sizes of this node's children, given the available
* space for this node. Note that "width" and "height" actually refer
* to the distance perpendicular and parallel to the sash respectively.
* That is, their meaning is reversed when computing a horizontal sash.
*
* @param width the pixel width of a vertical node, or the pixel height
* of a horizontal node (INF if unbounded)
* @param height the pixel height of a vertical node, or the pixel width
* of a horizontal node (INF if unbounded)
* @return a struct describing the pixel sizes of the left and right children
* (this is a width for horizontal nodes and a height for vertical nodes)
*/
ChildSizes ComputeChildSizes(int width, int height, int left, int right, int preferredWidth);
protected: int DoGetSizeFlags(bool width);
/**
* Resize the parts on this tree to fit in bounds
.
*/
public: void DoSetBounds(const QRect& bounds);
/* (non-Javadoc)
* @see org.blueberry.ui.internal.LayoutTree#createControl(org.blueberry.swt.widgets.Composite)
*/
- public: void CreateControl(void* parent);
+ public: void CreateControl(QWidget* parent);
//Added by hudsonr@us.ibm.com - bug 19524
public: bool IsCompressible();
/**
* Returns 0 if there is no bias. Returns -1 if the first child should be of
* fixed size, and the second child should be compressed. Returns 1 if the
* second child should be of fixed size.
* @return the bias
*/
public: int GetCompressionBias();
bool IsLeftChild(SmartPointer toTest);
SmartPointer GetChild(bool left);
/**
* Sets a child in this node
*/
void SetChild(bool left, LayoutPart::Pointer part);
/**
* Sets a child in this node
*/
void SetChild(bool left, SmartPointer child);
/**
* Returns a string representation of this object.
*/
public: QString ToString() const;
/**
* Create the sashes if the children are visible
* and dispose it if they are not.
*/
- //public: void UpdateSashes(void* parent);
+ //public: void UpdateSashes(QWidget* parent);
/**
* Writes a description of the layout to the given string buffer.
* This is used for drag-drop test suites to determine if two layouts are the
* same. Like a hash code, the description should compare as equal iff the
* layouts are the same. However, it should be user-readable in order to
* help debug failed tests. Although these are english readable strings,
* they should not be translated or equality tests will fail.
*
* @param buf
*/
public: void DescribeLayout(QString& buf) const;
private:
static QRect FlipRect(const QRect& rect);
};
}
#endif /*BERRYLAYOUTTREENODE_H_*/
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
index d7bab9d5ed..e7d3b87920 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryPartPane.cpp
@@ -1,464 +1,464 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "tweaklets/berryGuiWidgetsTweaklet.h"
#include "berryPartPane.h"
#include "tweaklets/berryWorkbenchPageTweaklet.h"
#include "berryWorkbenchPage.h"
#include "berryPartStack.h"
#include "berryEditorAreaHelper.h"
#include "berryPerspective.h"
#include "berryPartStack.h"
#include "berryDragUtil.h"
namespace berry
{
PartPane::Sashes::Sashes() :
left(0), right(0), top(0), bottom(0)
{
}
PartPane::PartPane(IWorkbenchPartReference::Pointer partReference,
WorkbenchPage* workbenchPage)
: LayoutPart(partReference->GetId()),
control(0), inLayout(true), busy(false), hasFocus(false)
{
//super(partReference.getId());
this->partReference = partReference;
this->page = workbenchPage;
}
-void PartPane::CreateControl(void* parent) {
+void PartPane::CreateControl(QWidget* parent) {
if (this->GetControl() != 0)
{
return;
}
partReference.Lock()->AddPropertyListener(this);
// Create view form.
control = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreatePaneControl(parent);
// the part should never be visible by default. It will be made visible
// by activation. This allows us to have views appear in tabs without
// becoming active by default.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(control, false);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(control, 0);
// Create a title bar.
//this->CreateTitleBar();
// When the pane or any child gains focus, notify the workbench.
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(control, GuiTk::IControlListener::Pointer(this));
//control.addTraverseListener(traverseListener);
}
PartPane::~PartPane()
{
// super.dispose();
//
this->Register();
if (control != 0)
{
BERRY_DEBUG << "Deleting PartPane control";
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(control, GuiTk::IControlListener::Pointer(this));
// control.removeTraverseListener(traverseListener);
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(control);
control = 0;
}
// if ((paneMenuManager != null))
// {
// paneMenuManager.dispose();
// paneMenuManager = null;
// }
//
if (!partReference.Expired())
{
partReference.Lock()->RemovePropertyListener(this);
}
// partReference.removePartPropertyListener(this);
this->UnRegister(false);
}
void PartPane::DoHide()
{
if (partReference.Lock().Cast() != 0)
{
this->GetPage()->HideView(partReference.Lock().Cast());
}
else if (partReference.Lock().Cast() != 0)
{
this->GetPage()->CloseEditor(partReference.Lock().Cast(), true);
}
}
QRect PartPane::GetParentBounds()
{
- void* ctrl = this->GetControl();
+ QWidget* ctrl = this->GetControl();
if (this->GetContainer() != 0 && this->GetContainer().Cast() != 0)
{
LayoutPart::Pointer part = this->GetContainer().Cast();
if (part->GetControl() != 0)
{
ctrl = part->GetControl();
}
}
return DragUtil::GetDisplayBounds(ctrl);
}
-void* PartPane::GetControl()
+QWidget* PartPane::GetControl()
{
return control;
}
IWorkbenchPartReference::Pointer PartPane::GetPartReference() const
{
return partReference.Lock();
}
void PartPane::ControlActivated(GuiTk::ControlEvent::Pointer /*e*/)
{
if (inLayout)
{
this->RequestActivation();
}
}
GuiTk::IControlListener::Events::Types PartPane::GetEventTypes() const
{
return GuiTk::IControlListener::Events::ACTIVATED;
}
-void PartPane::MoveAbove(void* refControl)
+void PartPane::MoveAbove(QWidget* refControl)
{
if (this->GetControl() != 0)
{
Tweaklets::Get(GuiWidgetsTweaklet::KEY)->MoveAbove(this->GetControl(), refControl);
}
}
void PartPane::RequestActivation()
{
IWorkbenchPart::Pointer part = partReference.Lock()->GetPart(true);
this->page->RequestActivation(part);
}
//PartStack::Pointer PartPane::GetStack()
//{
// return partStack;
//}
PartPane::Sashes PartPane::FindSashes()
{
Sashes result;
ILayoutContainer::Pointer container = this->GetContainer();
if (container == 0) {
return result;
}
container->FindSashes(LayoutPart::Pointer(this), result);
return result;
}
WorkbenchPage::Pointer PartPane::GetPage()
{
return WorkbenchPage::Pointer(page);
}
void PartPane::SetContainer(ILayoutContainer::Pointer container)
{
if (hasFocus)
{
ILayoutContainer::Pointer oldContainer = this->GetContainer();
if (PartStack::Pointer oldStack = oldContainer.Cast())
{
oldStack->SetActive(StackPresentation::AS_INACTIVE);
}
if (PartStack::Pointer newContainer = container.Cast())
{
newContainer->SetActive(StackPresentation::AS_ACTIVE_FOCUS);
}
}
- void* containerControl = container == 0 ? 0 : container.Cast()->GetControl();
+ QWidget* containerControl = container == 0 ? 0 : container.Cast()->GetControl();
if (containerControl != 0)
{
- void* control = this->GetControl();
- void* newParent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(containerControl);
+ QWidget* control = this->GetControl();
+ QWidget* newParent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(containerControl);
if (control != 0 && newParent != Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetParent(control))
{
this->Reparent(newParent);
}
}
LayoutPart::SetContainer(container);
}
-void PartPane::Reparent(void* newParent)
+void PartPane::Reparent(QWidget* newParent)
{
- void* control = this->GetControl();
+ QWidget* control = this->GetControl();
GuiWidgetsTweaklet* guiTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY);
if ((control == 0) || (guiTweaklet->GetParent(control) == newParent))
{
return;
}
if (guiTweaklet->IsReparentable(control))
{
// make control small in case it is not resized with other controls
//control.setBounds(0, 0, 0, 0);
// By setting the control to disabled before moving it,
// we ensure that the focus goes away from the control and its children
// and moves somewhere else
bool enabled = guiTweaklet->GetEnabled(control);
guiTweaklet->SetEnabled(control, false);
guiTweaklet->SetParent(control, newParent);
guiTweaklet->SetEnabled(control, enabled);
guiTweaklet->MoveAbove(control, 0);
}
}
void PartPane::ShowFocus(bool inFocus)
{
if (partReference.Lock().Cast() != 0)
{
hasFocus = inFocus;
}
if (PartStack::Pointer stack = this->GetContainer().Cast())
{
if (partReference.Lock().Cast() != 0)
{
stack->SetActive(inFocus ? StackPresentation::AS_ACTIVE_FOCUS
: StackPresentation::AS_INACTIVE);
}
else if (partReference.Lock().Cast() != 0)
{
if (inFocus)
{
page->GetEditorPresentation()->SetActiveWorkbook(stack, true);
}
else
{
stack->SetActive(page->GetEditorPresentation()->GetActiveWorkbook() == stack ?
StackPresentation::AS_ACTIVE_NOFOCUS : StackPresentation::AS_INACTIVE);
}
}
}
}
PartStack::Pointer PartPane::GetStack()
{
ILayoutContainer::Pointer container = this->GetContainer();
return container.Cast